用ruby2不能要求mysql2

时间:2013-08-28 08:59:53

标签: mysql2 ruby-2.0

我已使用RVM将我的ruby版本更新为2.0.0。然后安装了mysql2 gem

-> % gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.13
1 gem installed
Installing ri documentation for mysql2-0.3.13...
Building YARD (yri) index for mysql2-0.3.13...
Installing RDoc documentation for mysql2-0.3.13...

之后我尝试在irb中要求mysql2。但它导致以下错误!

-> % irb
2.0.0p247 :001 > require 'mysql2'
LoadError: cannot load such file -- mysql2/mysql2
    from /home/sayuj/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
    from /home/sayuj/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
    from /home/sayuj/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
    from /home/sayuj/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in `require'
    from /home/sayuj/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in `rescue in require'
    from /home/sayuj/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:35:in `require'
    from (irb):1
    from /home/sayuj/.rvm/rubies/ruby-2.0.0-p247/bin/irb:16:in `<main>'

我该如何解决?请帮帮我。

1 个答案:

答案 0 :(得分:0)

更新您的RVM rvm get stable 并重新安装ruby2

rvm uninstall ruby-2.0.0-p247
rvm install ruby-2.0.0-p247

这样可行。