我是ruby on rails的新手我无法找到此错误的解决方案:
rails s
/usr/local/share/gems/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from /usr/local/share/gems/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /usr/local/share/gems/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/Harish/Documents/simple_cms/config/application.rb:7:in `<top (required)>'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /usr/local/share/gems/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
答案 0 :(得分:9)
gem uninstall mysql2
gem install mysql2 --platform=ruby
删除rails特定包目录中的mysql2 gem目录并复制粘贴这个新安装的mysql2 gem
答案 1 :(得分:4)
对于Rails 3.2.17和Ruby 1.9.3-p448以及mysql2 0.3.11,运行bundle update mysql2
更新为0.3.15并为我摆脱了错误。
答案 2 :(得分:1)
Ya,正在使用带有rails 4.0.0的mysql2 gem的新版本(0.3.13)。删除供应商目录下的捆绑文件夹,并重新运行捆绑安装,更新为我解决了这个问题
cd {Your_RailsApp_Root}/vendor/
rm -rf bundle/
cd {Your_RailsApp_Root}
bundle install
bundle update
答案 3 :(得分:0)
你是否安装了mysql2 gem?检查您的gemfile是否为gem "mysql2"
,然后从rails应用程序的根目录运行bundle install
。另外,请确保在开发环境中下载了mysql。
答案 4 :(得分:0)
刚刚降级了mysql2版本。在我的情况下,我使用'0.2.6'版本,它适用于我。
gem 'mysql2', '0.2.6'
使用ruby版本2.0.0和gem版本1.8.25
答案 5 :(得分:0)
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
来自
https://gorails.com/setup/osx/10.14-mojave
答案 6 :(得分:-1)
对我有用。
答案 7 :(得分:-4)
这解决了我的错误:
[root @ localhost cms] #su Harish
[Harish @ localhost cms] $ bundle install
[Harish @ localhost cms] $ rails s