我有这个版本,我无法更改ruby和rails版本
当我尝试在Ubuntu上运行rails server command
时,我收到此错误
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'mysql2'.
Gem Load Error is: uninitialized constant Mysql2::Client::SECURE_CONNECTION
Backtrace for gem load error is:
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.9/lib/mysql2/client.rb:12:in `<class:Client>'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.9/lib/mysql2/client.rb:2:in `<module:Mysql2>'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.9/lib/mysql2/client.rb:1:in `<top (required)>'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.9/lib/mysql2.rb:9:in `<top (required)>'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:82:in `require'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:77:in `each'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:77:in `block in require'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:66:in `each'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:66:in `require'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.15.4/lib/bundler.rb:108:in `require'
/home/xyz/Documents/trailtap-api/config/application.rb:9:in `<top (required)>'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/xyz/Documents/trailtap-api/Rakefile:4:in `<top (required)>'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/rake_module.rb:28:in `load'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/rake_module.rb:28:in `load_rakefile'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:689:in `raw_load_rakefile'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:94:in `block in load_rakefile'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:93:in `load_rakefile'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:77:in `block in run'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/home/xyz/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/home/xyz/.rbenv/versions/1.9.2-p290/bin/rake:23:in `load'
/home/xyz/.rbenv/versions/1.9.2-p290/bin/rake:23:in `<main>'
Bundler Error Backtrace:
/home/xyz/Documents/trailtap-api/config/application.rb:9:in `<top (required)>'
/home/xyz/Documents/trailtap-api/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
我认为gem文件需要更新,所以我更新了它,但是mysql2不支持rails版本,也没有发送活动记录适配器,即使安装了适配器gem之后它也失败了。
提前致谢。
答案 0 :(得分:0)
查看此文章:uninitialized constant Mysql2::Client::SECURE_CONNECTION
解决方案是升级mysql2。在您的情况下,可能值得尝试降级该版本,看看它是否解决了您的问题。
另外,请确保libmysqlclient-dev
和ruby-mysql
已安装并且是最新的
答案 1 :(得分:0)
尝试
gem 'rails', '3.0.9'
gem 'mysql2', "0.2.24"