执行文件“dbTest.rb”时:
require 'mysql'
con = Mysql::new("192.168.10.70", "dbuser", "asd1234", "asd")
puts con.get_server_info
经过 :
ruby dbTest.rb
我得到错误:
dbTest.rb:1:in `require': no such file to load -- mysql (LoadError)
当我执行 "gem list" 时,我看到 mysql、mysql2 和 dbd-mysql 都在那里。你能指出我的错误吗?提前谢谢您的时间。
干杯!
编辑 :
由于我不知道的原因,我有两个 1.8 版本,但 gem 正在与正确的 ruby 对话:
cem@skynet:/usr/bin$ sudo update-alternatives --config ruby
[sudo] password for cem:
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/ruby1.8 50 auto mode
1 /usr/bin/ruby1.8 50 manual mode
2 /usr/bin/ruby1.9.1 10 manual mode
Press enter to keep the current choice[*], or type selection number:
cem@skynet:/usr/bin$ sudo update-alternatives --config gem
There are 2 choices for the alternative gem (providing /usr/bin/gem).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gem1.8 180 auto mode
1 /usr/bin/gem1.8 180 manual mode
2 /usr/bin/gem1.9.1 10 manual mode
Press enter to keep the current choice[*], or type selection number: