从 14.10 升级到 15.04 后,当我启动 rails 服务器时出现以下错误:
arslion@arslion-Lenovo-B570e:~$ rails s
/home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/mysql2-0.3.18/lib/mysql2.rb:31:in `require': Incorrect MySQL client library version! This gem was compiled for 5.5.43 but the client library is 5.6.24. (RuntimeError)
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/mysql2-0.3.18/lib/mysql2.rb:31:in `<top (required)>'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
from /home/arslion/config/application.rb:14:in `<top (required)>'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:79:in `require'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `server'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
from /home/arslion/bin/rails:8:in `require'
from /home/arslion/bin/rails:8:in `<top (required)>'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /home/arslion/.rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/arslion/bin/spring:16:in `require'
from /home/arslion/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
答案1
卸载并重新安装 gem 通常可以解决问题。这个解决方案对我来说很有效。
gem uninstall mysql2
进而bundle install
希望有效。