[英]Ruby Gem adaptor MySQL error
I am getting the below error while using the MySQL gem; 使用MySQL gem时出现以下错误; Tried mysql2 and it also gives the same error.
尝试了mysql2,它也给出了相同的错误。
-bash-4.1$ gem list
*** LOCAL GEMS ***
mysql (2.9.1)
-bash-4.1$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
-bash-4.1$ irb
irb(main):001:0> require 'mysql'
NameError: uninitialized constant Mysql
from ./mysql.rb:10
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0>
Please let me know if there is a solution for this; 请让我知道是否有解决方案; thanks!
谢谢!
Are you using bundler/rvm? 您在使用捆绑程序/ rvm吗? If so, start irb with:
如果是这样,请使用以下命令启动irb:
bundle exec irb
make sure you are in the right gemset
and ruby version
from where you are accessing the gem. 确保你是在正确的
gemset
和ruby version
从您正在访问的宝石。 Before typing in the irb
, check what gemset you are in: 在输入
irb
之前,请检查您所在的gemset:
rvm gemset list
then check the gems installed in that particular gemset 然后检查安装在该特定宝石集中的宝石
rvm <my-gemset-name> do gem list
If they do not match, that is your problem and you can fix it by changing to the right gemset: 如果它们不匹配,那就是您的问题,您可以通过更改为正确的gemset来解决:
rvm use <my-gemset>
Similarly, check for ruby version, ie if the ruby version for your installed gem and from where you are running your irb match 同样,检查Ruby版本,即是否已安装gem的Ruby版本以及运行irb的位置是否匹配
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.