When I install the 2.7.3 “mysql” gem on Windows XP (trying to prepare
for the requirement to use the mysql gem in Rails 2.2.2) by using:
gem install mysql
I get a mysql-2.7.3-x86-mswin32 directory under gems, but underneath
that, only a docs directory, an ext directory, and README, Rakefile and
.require_paths.
I then cannot do any connecting to my MySQL databases.
Shouldn’t there be a “lib” directory under the mysql gem directory?
Can you determine what dates are associated with the files? In
particular, was mysql.so created when you did the “gem install…”?
Also, the test.rb can be usefull. Assuming you have a mysql database
named “testDB” that is owned by user “test” who’s mysql password is
“test”, the following command:
ruby ./test.rb – localhost test test testDB
will run an array of tests on your mysql ruby access. They should ALL
pass.
C:\Development\ruby\lib\ruby\gems\1.8\gems\mysql-2.7.3-x86-mswin32\ext>ruby
test
.rb – localhost test test testDB
Loaded suite test
Started
…C:/Development/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:3
1: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application’s support team for more information.
Can you determine what dates are associated with the files? In
particular, was mysql.so created when you did the “gem install…”?
Also, the test.rb can be usefull. Assuming you have a mysql database
named “testDB” that is owned by user “test” who’s mysql password is
“test”, the following command:
ruby ./test.rb – localhost test test testDB
will run an array of tests on your mysql ruby access. They should ALL
pass.
C:\ruby\lib\ruby\gems\1.8\gems\mysql-2.7.3-x86-mswin32\ext>ruby test.rb
– local
host test test testDB
Loaded suite test
Started
.FE…C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:497: [BUG]
Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application’s support team for more information.
I’m under the assumption that the mysql gem for Windows is precompiled,
like all of the other gems for Windows (generally speaking), so there
isn’t really a compilation step.
Here’s the output from the --verbose run. I notice that it can’t find
the
H:>gem install mysql --verbose
HEAD 200 OK: RubyGems.org | your community gem host
GET 200 OK: RubyGems.org | your community gem host
Installing gem mysql-2.7.3-x86-mswin32
Downloading gem mysql-2.7.3-x86-mswin32.gem
GET 302 Found: RubyGems.org | your community gem host
GET 404 Not Found: http://gems.rubyforge.vm.bytemark.co.uk/gems/mysql-2.7.3-x86-
mswin32.gem
Failed, downloading gem mysql-2.7.3-mswin32.gem
GET 302 Found: RubyGems.org | your community gem host
GET 200 OK: http://gemmirror.xaop.net/gems/mysql-2.7.3-mswin32.gem
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.so
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/extconf.rb
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.c.in
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.c.in.patch
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/test.rb
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/README
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/Rakefile
C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/docs/README.html
Successfully installed mysql-2.7.3-x86-mswin32
1 gem installed
Installing ri documentation for mysql-2.7.3-x86-mswin32…
Installing RDoc documentation for mysql-2.7.3-x86-mswin32…
ERROR: While generating documentation for mysql-2.7.3-x86-mswin32
… MESSAGE: Unhandled special: Special: type=17, text=“”
… RDOC args: --op
C:/ruby/lib/ruby/gems/1.8/doc/mysql-2.7.3-x86-mswin32/rdoc -
-exclude ext --main README --quiet ext README docs/README.html
(continuing with the rest of the installation)
So it looks like you are downloading a pre-compiled gem.
I’m not sure how much of this you understand but the mysql gem is
different from most ruby gems in that it is a compiled interface
implements a ruby interface to the mysqlclient API.
My guess is that the mysql…so file that ships with your gem is not
correct for your system. I’m a little fuzzy here on the finer points
of the mswin32 and 64 bit environments but I do know that there are
several ways to get a miss-match.
On my system, Mac OS X, I start from the source and compile the gem as
part of the install step. This reduces the likelyhood of a miss-
matched executable but causes more work preparing for the compile.
It’s the preparation part that appeared to be broken for me but I’ve
figured out how to fix that and built a functioning gem.
Do you have a c compiler on your system? If so, have you ever used it
and do you want to give compiling your gem a shot?
Actually, getting the MySQL gem to install on Mac OS X was no mean fit
given the 32/64 bit issues with the version of Ruby that ships with OS
X. But I did get that working the other day.
I’m comfortable compiling stuff on OS X.
This exercise was to set up my Windows XP VM - to be honest, I can’t
even remember why I was even bothering to try to install the mysql gem
on my Windows VM.
I’m not going to bother moving forward on it unless I need it.
Right, I gave up on what ships with Mac and just built everything
fresh in /opt/local. That’s a good place to put your precious stuff
BTW because a reinstall or major upgrade of OSX will trash /usr/local.
I remember now why I was trying to get this to work.
Because the built-in support for MySQL has been pulled out of Rails 2.2,
I was just trying to anticipate any 2.2 projects that I needed to
run/handle on Windows.
I saw that you had posted on “mysql” 2.7.3 gem install for Windows
issue. I noticed you said you probably wouldn’t pursue it, but I was
wondering if you had any success since then?
I did copy the libmysql.dll file into ruby/bin/ as mentioned here (as
well as in the README.html file associated with the gem), but without
success:
I saw that you had posted on “mysql” 2.7.3 gem install for Windows
issue. I noticed you said you probably wouldn’t pursue it, but I was
wondering if you had any success since then?
No, still haven’t resolved it. Hoping that the next release of the
mysql gem for Windows will work better.
I used mysql-5.0.67-win32 instead of the 5.1.30-win32 as jason_46
suggested. I follow everything else he says, except I am running
WEBrick instead of Mongrel. And finally, while the DOS prompt showed
that the PATH variable was already set to “C:\Program Files\MySQL
\MySQL Server 5.0\bin” (among other directories), I just copied
libmySQL.dll from “My SQL Server 5.0\bin” into “WINDOWS\System32” and
“ruby\bin” for kicks.
While this may not be a very elegant way to handle potential PATH
issues, it did the trick for me, so I’m not planning on messing with
it for now. Hope this is helpful.
Copy the file libmysql.dll from mysql/bin to ruby/bin.
It worked for me. Environment starts and app executes properly in
2.2.2 now. Still get the rdoc error when installing mysql, but it
doesn’t seem to affect the environment.