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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了`block in replace_gem': Please install the mysql2 adapter: `gem install activerecord-mysql2-adap相关的知识,希望对你有一定的参考价值。

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

[email protected]:/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-adap的主要内容,如果未能解决你的问题,请参考以下文章

IE block my cookie in iframe

Using ffmpeg libraries in Code::Blocks

Moving From Top To Bottom in Detailed Block in Oracle Forms

手动修复 under-replicated blocks in HDFS

Code block of anonymous object in Java

错误:__tcp_connection_write_eof_block_invoke 写入关闭回调收到错误 - iOS 10