码迷,mamicode.com
首页 > 数据库 > 详细

`block in replace_gem': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter`

时间:2016-02-01 15:11:42      阅读:474      评论:0      收藏:0      [点我收藏+]

标签:

在执行rails s时出现“`block in replace_gem‘: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter`”错误:

diudiugirl@DIUs:/var/www/ashelf$ rails s
=> Booting WEBrick
=> Rails 3.2.22.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:314:in `block in replace_gem: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (cant activate mysql2 (~> 0.3.10), already activated mysql2-0.4.2. Make sure all dependencies are added to Gemfile.) (LoadError)
from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:251:in `requirefrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:251:in `block in requirefrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:236:in `load_dependencyfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:251:in `requirefrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connectionfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connectionfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `specfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connectionfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_evalfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hookfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/lazy_load_hooks.rb:26:in `block in on_loadfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/lazy_load_hooks.rb:25:in `eachfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/lazy_load_hooks.rb:25:in `on_loadfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.1/lib/active_record/railtie.rb:80:in `block in <class:Railtie>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/initializable.rb:30:in `instance_execfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/initializable.rb:30:in `runfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/initializable.rb:55:in `block in run_initializersfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/initializable.rb:54:in `eachfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/initializable.rb:54:in `run_initializersfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/application.rb:136:in `initialize!from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/railtie/configurable.rb:30:in `method_missingfrom /var/www/ashelf/config/environment.rb:5:in `<top (required)>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:251:in `requirefrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:251:in `block in requirefrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:236:in `load_dependencyfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.1/lib/active_support/dependencies.rb:251:in `requirefrom /var/www/ashelf/config.ru:3:in `block in <main>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_evalfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initializefrom /var/www/ashelf/config.ru:in `newfrom /var/www/ashelf/config.ru:in `<main>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/builder.rb:40:in `evalfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/builder.rb:40:in `parse_filefrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/server.rb:200:in `appfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/commands/server.rb:46:in `appfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/server.rb:304:in `wrapped_appfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/server.rb:254:in `startfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/commands/server.rb:70:in `startfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/commands.rb:55:in `block in <top (required)>from /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/commands.rb:50:in `tapfrom /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.1/lib/rails/commands.rb:50:in `<top (required)>from script/rails:6:in `requirefrom script/rails:6:in `<main>

 

解决方法:

在Gemfile中加入:

gem ‘mysql2‘
gem ‘activerecord-mysql2-adapter‘

再执行bundle install 即可。

`block in replace_gem': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter`

标签:

原文地址:http://www.cnblogs.com/Sophiawow/p/5174889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!