关于rails上的ruby:无法加载’active_record / connection_adapters / sqlite3_adapter’。 在win7 64bit

Could not load 'active_record/connection_adapters/sqlite3_adapter'. in win7 64bit

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服务器没问题,但是当访问网站时它返回此错误:

1
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.

相关信息:

1
2
3
4
5
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

(required)>'
activesupport (4.1.6) lib/active_support/dependencies.rb:247:inrequire'
activesupport (4.1.6) lib/active_support/dependencies.rb:247:in block in require'
activesupport (4.1.6) lib/active_support/dependencies.rb:232:inload_dependency'
activesupport (4.1.6) lib/active_support/dependencies.rb:247:in require'
activerecord (4.1.6) lib/active_record/connection_adapters/connection_specification.rb:188:inspec'
activerecord (4.1.6) lib/active_record/connection_handling.rb:50:in establish_connection'
activerecord (4.1.6) lib/active_record/railtie.rb:129:inblock (2 levels) in class:Railtie'
activesupport (4.1.6) lib/active_support/lazy_load_hooks.rb:38:in instance_eval'
activesupport (4.1.6) lib/active_support/lazy_load_hooks.rb:38:inexecute_hook'
activesupport (4.1.6) lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks'
activesupport (4.1.6) lib/active_support/lazy_load_hooks.rb:44:ineach'
activesupport (4.1.6) lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks'
activerecord (4.1.6) lib/active_record/base.rb:326:inmodule:ActiveRecord'
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
in call'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:619:in
call'
activerecord (4.1.6) lib/active_record/migration.rb:380:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in block in call'
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'
actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in call'
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'
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'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:inblock in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:intagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in call'
actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call'
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
call'
rack (1.5.2) lib/rack/lock.rb:17:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in call'
rack (1.5.2) lib/rack/sendfile.rb:112:incall'
railties (4.1.6) lib/rails/engine.rb:514:in call'
railties (4.1.6) lib/rails/application.rb:144:incall'
rack (1.5.2) lib/rack/lock.rb:17:in call'
rack (1.5.2) lib/rack/content_length.rb:14:incall'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in service'
E:/Tool/Ruby21-x64/lib/ruby/2.1.0/webrick/httpserver.rb:138:inservice'
E:/Tool/Ruby21-x64/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run'
E:/Tool/Ruby21-x64/lib/ruby/2.1.0/webrick/server.rb:295:inblock in start_thread'


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

1
2
gem uninstall sqlite3
bundle install

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


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

1
gem install sqlite3

在命令行上,并修复了错误。


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

1
gem 'sqlite3', '1.3.9'