1

When executing the file "dbTest.rb" :

require 'mysql'
con = Mysql::new("192.168.10.70", "dbuser", "asd1234", "asd")
puts con.get_server_info

By :

ruby dbTest.rb

I get the error :

dbTest.rb:1:in `require': no such file to load -- mysql (LoadError)

When I execute "gem list" , I see mysql, mysql2 and dbd-mysql all there. Can you point out my error ? Thx in advance for your time.

Cheers !

Edit :

For the reasons that are unknown to me I have two 1.8 versions but the gem is talking to the right 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:
Pumpkin
  • 1,993
  • 3
  • 26
  • 32
  • Since you are using a older version of ruby, you might want to check to see that the version of mysql gem is combatiable with the version of ruby you are trying to use – Egryan Dec 31 '12 at 14:11

1 Answers1

5

Since you are using Ruby 1.8 I believe require 'rubygems' is required:

require 'rubygems'
require 'mysql'
con = Mysql::new("192.168.10.70", "dbuser", "asd1234", "asd")
puts con.get_server_info

If you wish to know more, checkout the answer at "How does require rubygems help find rubygem files?".

Community
  • 1
  • 1
Eugene Rourke
  • 4,934
  • 1
  • 22
  • 24