From: "Jesús Gabriel y Galán" Date: 2010-09-06T19:02:00+09:00 Subject: Re: Problems using the Mysql gem On Mon, Sep 6, 2010 at 11:27 AM, Jim Burgess wrote: > Hi, > > I'm using the mysql (2.8.1 x86-mingw32) gem and MySQL Server version > 5.0.90 on Windows 7, 64 bit. I'm also using ruby 1.8.7. > > When I run the following script (replacing user name and password > appropriately) > > require "rubygems" > require "mysql" > dbh = Mysql.real_connect("localhost", "user", "pass", "test") > puts "Server version: " + dbh.get_server_info > dbh.close > > I get the following error message: > > ./test.rb:3: uninitialized constant Mysql (NameError) > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in > `gem_original_require' > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in > `require' > from mysql.rb:2 >>Exit code: 1 > > Can anyone give me a pointer as to what is going wrong? > I have tried googling the error message, but with no luck. > I have also read the documentation installed with the gem and as far as > I can tell I am using the correct syntax. I can't test it in Windows, but I've tested in Ubuntu with Ruby 1.8.7 and mysql gem 2.8.1 and it works. Line 2 of mysql.rb is doing a require of mysql_api, which in Ubuntu loads a mysql_api.so from the same folder. Did the gem install correctly in Windows? I guess you should have a mysql_api dll somewhere in your gem structure. I'm just guessing, since I don't know how the mysql gem installs under Windows, but maybe this gives you some clue. In fact, taking a look at the code: begin require 'mysql_api' rescue LoadError if RUBY_PLATFORM =~ /mingw|mswin/ then RUBY_VERSION =~ /(\d+.\d+)/ require "#{$1}/mysql_api" end end it seems that if requiring mysql_api fails and the platform is Windows, it tries to load a specific version. Does that help? Jesus.