我刚从另一台计算机上下载了rails项目。我在我的电脑上安装了RubyMine,Rails,Ruby,DevKit,SQLite3(Windows的最新版本)。我通过控制台安装了所有的gemfiles。当我从控制台运行任何rake
命令时,它会抛出这个错误:
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>'
答案 0 :(得分:0)
仔细阅读错误。它声明:
无法加载&#39; active_record / connection_adapters / sqlite3_adapter&#39;。 确保config / database.yml中的适配器有效。如果你使用 除了&#39; mysql&#39;,&#39; mysql2&#39;,&#39; postgresql&#39;以外的适配器或者&#39; sqlite3&#39;加 Gemfile所需的适配器gem。 (LoadError)
这清楚地表明您的应用程序配置不正确。
正如您提到&#34;我刚刚从另一台计算机上下载了rails项目&#34; ,您可能还没有安装Gems。
假设您的计算机中已安装Ruby和bundler,请执行以下步骤:
bundle install
完成所有这些后:
找到你的sqlite3 gemspec文件。一个例子是
C:\Ruby21\lib\ruby\gems\2.1.0\specifications
您应该根据您的Rubygem路径和sqlite3版本进行调整。编辑上面的文件并查找以下行
s.require_paths=["lib"]
将其更改为
s.require_paths= ["lib/sqlite3_native"]
答案 1 :(得分:0)
我不确定发生了哪些变化,我无法找到任何相关文档,但似乎在ruby 2.2中,某些内容因安装了带有原生扩展的gem而发生了变化应该在他们的gem包中提供预编译的二进制文件。在以前版本的ruby中,如果安装了rdevkit,那么本机扩展通常可以在本地构建(有一些例外,比如mysql)。
我遇到了同样的问题并通过卸载ruby 2.2并安装ruby 2.1(使用rubyinstaller)解决了这个问题。当大多数宝石支持它时,我会再回来尝试2.2。