无法加载' active_record / connection_adapters / sqlite3_adapter'。在win7 64bit

时间:2014-09-23 06:25:31

标签: ruby-on-rails ruby

Ruby版本:ruby 2.1.3p242(2014-09-19修订版47630)[x64-mingw32]

Rails版本:Rails 4.1.6

寡妇:win7 64bit

sqlite3-1.3.9-x64-mingw32.gemspec已更改为s.require_paths = [" lib / sqlite3_native"]

Ruby / Bin中的sqlite3.dll和Gemfile的sqlite3版本与Gemfile.lock相同,rails服务器没问题,但是当访问网站时它返回此错误:

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.

的相关信息:

activesupport (4.1.6) lib/active_support/dependencies.rb:247:in require'
activesupport (4.1.6) lib/active_support/dependencies.rb:247:inblock in require'
activesupport (4.1.6) lib/active_support/dependencies.rb:232:in load_dependency'
activesupport (4.1.6) lib/active_support/dependencies.rb:247:inrequire'
activerecord (4.1.6) lib/active_record/connection_adapters/sqlite3_adapter.rbin <top
     

(必需)&GT;&#39;       activesupport(4.1.6)lib / active_support / dependencies.rb:247:inrequire&#39;       activesupport(4.1.6)lib / active_support / dependencies.rb:247:在require&#39;中的块中       activesupport(4.1.6)lib / active_support / dependencies.rb:232:inload_dependency&#39;       activesupport(4.1.6)lib / active_support / dependencies.rb:247:in require&#39;       activerecord(4.1.6)lib / active_record / connection_adapters / connection_specification.rb:188:inspec&#39;       activerecord(4.1.6)lib / active_record / connection_handling.rb:50:在establish_connection&#39;       activerecord(4.1.6)lib / active_record / railtie.rb:129:inblock(2级)在课堂上:Railtie&#39;       activesupport(4.1.6)lib / active_support / lazy_load_hooks.rb:38:in instance_eval&#39;       activesupport(4.1.6)lib / active_support / lazy_load_hooks.rb:38:inexecute_hook&#39;       activesupport(4.1.6)lib / active_support / lazy_load_hooks.rb:45:在run_load_hooks&#39;中的块中       activesupport(4.1.6)lib / active_support / lazy_load_hooks.rb:44:ineach&#39;       activesupport(4.1.6)lib / active_support / lazy_load_hooks.rb:44:在run_load_hooks&#39;       activerecord(4.1.6)lib / active_record / base.rb:326:inmodule:ActiveRecord&#39;       activerecord(4.1.6)lib / active_record / base.rb:23:in'       activerecord(4.1.6)lib / active_record / connection_adapters / abstract / connection_pool.rb:628:inrescue   在电话中&#39;       activerecord(4.1.6)lib / active_record / connection_adapters / abstract / connection_pool.rb:619:in   叫&#39;       activerecord(4.1.6)lib / active_record / migration.rb:380:incall&#39;       actionpack(4.1.6)lib / action_dispatch / middleware / callbacks.rb:29:in block in call&#39;       activesupport(4.1.6)lib / active_support / callbacks.rb:82:inrun_callbacks'       actionpack(4.1.6)lib / action_dispatch / middleware / callbacks.rb:27:in call&#39;       actionpack(4.1.6)lib / action_dispatch / middleware / reloader.rb:73:incall&#39;       actionpack(4.1.6)lib / action_dispatch / middleware / remote_ip.rb:76:in call&#39;       actionpack(4.1.6)lib / action_dispatch / middleware / debug_exceptions.rb:17:incall'       actionpack(4.1.6)lib / action_dispatch / middleware / show_exceptions.rb:30:in call&#39;       railties(4.1.6)lib / rails / rack / logger.rb:38:incall_app'       railties(4.1.6)lib / rails / rack / logger.rb:20:in block in call&#39;       activesupport(4.1.6)lib / active_support / tagged_logging.rb:68:inblock in tagged&#39;       activesupport(4.1.6)lib / active_support / tagged_logging.rb:26:in tagged&#39;       activesupport(4.1.6)lib / active_support / tagged_logging.rb:68:凹版&#39;       railties(4.1.6)lib / rails / rack / logger.rb:20:in call&#39;       actionpack(4.1.6)lib / action_dispatch / middleware / request_id.rb:21:incall'       rack(1.5.2)lib / rack / methodoverride.rb:21:in call&#39;       rack(1.5.2)lib / rack / runtime.rb:17:incall'       activesupport(4.1.6)lib / active_support / cache / strategy / local_cache_middleware.rb:26:in   叫&#39;       rack(1.5.2)lib / rack / lock.rb:17:incall'       actionpack(4.1.6)lib / action_dispatch / middleware / static.rb:64:in call&#39;       rack(1.5.2)lib / rack / sendfile.rb:112:incall&#39;       railties(4.1.6)lib / rails / engine.rb:514:in call&#39;       railties(4.1.6)lib / rails / application.rb:144:incall&#39;       rack(1.5.2)lib / rack / lock.rb:17:in call&#39;       rack(1.5.2)lib / rack / content_length.rb:14:incall'       rack(1.5.2)lib / rack / handler / webrick.rb:60:in service&#39;       E:/Tool/Ruby21-x64/lib/ruby/2.1.0/webrick/httpserver.rb:138:役&#39;       E:/Tool/Ruby21-x64/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run&#39;       E:/Tool/Ruby21-x64/lib/ruby/2.1.0/webrick/server.rb:295:start_thread中的inblock&#39;

3 个答案:

答案 0 :(得分:2)

我的解决方案(Win7 x64)是卸载所有不必要的sqlite3版本。我安装了1.3.9,1.3.10和1.3.11,所以我删除了.9和.10并更新了我的gemfile以使用.11。

gem uninstall sqlite3
bundle install

使用1.3.11我不需要应用你提到的s.require_paths=["lib/sqlite3_native"] hack。

答案 1 :(得分:1)

我遇到了同样的错误,安装了相同版本的sqlite3 gem,并且也改变了特定的gemspec路径。环顾四周后我做了一个简单的

gem install sqlite3

在命令行上修复了错误。

答案 2 :(得分:-3)

转到您应用的gemfile并将sqlite3 gem版本编辑为您已安装的版本。

gem 'sqlite3', '1.3.9'