1

I have just downloaded rails project from another computer. I have installed on my PC RubyMine, Rails, Ruby, DevKit, SQLite3 (Last versions for windows). I have installed all my gemfiles via console. When I run any rake command from console it throws me this error:

D:\SINOD\Programs\RUBY\Ruby_Projects\attendance\bin\rails
Error:D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:50:in `establish_connection'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-4.2.0/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in  `execute_hook'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:27:in `each'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-4.2.0/lib/active_record/railtie.rb:116:in `block in <class:Railtie>'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0 /gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:345:in `each'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:345:in `call'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
Error:  from D:/SINOD/Programs/RUBY/Ruby_Projects/attendance/config/environment.rb:5:in `<top (required)>'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
Error:  from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/application.rb:328:in `require_environment!'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:128:in `generate_or_destroy'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:50:in `generate'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
 Error: from D:/SINOD/Programs/RUBY/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
 Error: from D:/SINOD/Programs/RUBY/Ruby_Projects/attendance/bin/rails:4:in `require'
  Error:    from D:/SINOD/Programs/RUBY/Ruby_Projects/attendance/bin/rails:4:in `<main>'
zxcdsa980
  • 119
  • 2
  • 7

2 Answers2

0

Read the error carefully. It states:

Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)

This clearly shows your application is not configured properly.

As you mentioned "I have just downloaded rails project from another computer", there is also a possibility you may have not installed Gems.

Assuming Ruby and bundler is setup in your computer, follow these steps:

Once you have done all this:

Find your sqlite3 gemspec file. One example is

C:\Ruby21\lib\ruby\gems\2.1.0\specifications

You should adjust according with your Rubygem path and sqlite3 version. Edit the file above and look for the following line

s.require_paths=["lib"]

change it to

s.require_paths= ["lib/sqlite3_native"]

reference: https://stackoverflow.com/a/17762417/3035830

Community
  • 1
  • 1
shivam
  • 16,048
  • 3
  • 56
  • 71
  • I have done all of these things. After bundle install it gives me: `cannot load such file 00sqlite3/sqlite3_native` – zxcdsa980 Apr 06 '15 at 07:03
  • I have found 2 files with sqlite3 `sqlite3-1.3.10-x64-mingw32` and `sqlite3-ruby-1.3.3` changed both `["lib"]` to `["lib/sqlite3_native"]`. Still throws me this error. – zxcdsa980 Apr 06 '15 at 07:12
  • Its a window specific issue and solution varies. This this: download the required executable and the dll from http://www.sqlite.org/download.html extract to your ruby's bin (c:\Ruby192\bin) – shivam Apr 06 '15 at 07:14
  • I have followed sqlite installation according to this http://www.tutorialspoint.com/sqlite/sqlite_installation.htm In my first computer this project works fine. I have uploaded to another, that kind of errors appeared. – zxcdsa980 Apr 06 '15 at 07:20
0

I'm not sure where the change happened, I can't find any documentation on it, but it seems that in ruby 2.2 something has changed with the way gems with native extensions are installed and they are now supposed to be providing pre-compiled binaries in their gem packages. In previous versions of ruby, if you had rdevkit installed then the native extensions could usually be built locally (with a few exceptions like mysql).

I had this same problem and worked around it by uninstalling ruby 2.2 and installing ruby 2.1 (with rubyinstaller). I'll come back and try 2.2 again later when most gems are supporting it.

Segfault
  • 8,036
  • 3
  • 35
  • 54