执行文件"dbTest.rb"时:
require 'mysql'
con = Mysql::new("192.168.10.70", "dbuser", "asd1234", "asd")
puts con.get_server_info
Run Code Online (Sandbox Code Playgroud)
通过:
ruby dbTest.rb
Run Code Online (Sandbox Code Playgroud)
我收到错误:
dbTest.rb:1:in `require': no such file to load -- mysql (LoadError)
Run Code Online (Sandbox Code Playgroud)
当我执行"gem list"时,我看到mysql,mysql2和dbd-mysql都在那里.你能指出我的错误吗?Thx提前为您的时间.
干杯!
编辑:
由于我不知道的原因,我有两个1.8版本,但宝石正在与正确的红宝石交谈:
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:
Run Code Online (Sandbox Code Playgroud)
由于您使用的是Ruby 1.8,我认为require 'rubygems'是必需的:
require 'rubygems'
require 'mysql'
con = Mysql::new("192.168.10.70", "dbuser", "asd1234", "asd")
puts con.get_server_info
Run Code Online (Sandbox Code Playgroud)
如果您想了解更多信息,请查看" 如何使用rubygems帮助查找rubygem文件? "中的答案.
| 归档时间: |
|
| 查看次数: |
151 次 |
| 最近记录: |