"gem install mysql" fails

To sum this up, gem install mysql crashes when looking for version.h.
This is happening after a fresh install of Ruby, Ruby Gems, and the
Mysql gem. Shouldn't a fresh install of ruby create version.h and
place it in the correct directory?

john: uname -a
FreeBSD sporkit.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7
04:32:43 UTC 2006

john: ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-freebsd6.1]

john: gem list

*** LOCAL GEMS ***

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
rails (2.3.2)
rake (0.8.4)
rubygems-update (1.3.1)

To sum this up, gem install mysql crashes when looking for version.h.
This is happening after a fresh install of Ruby, Ruby Gems, and the
Mysql gem. Shouldn't a fresh install of ruby create version.h and
place it in the correct directory?

I think version.h disappeared in ruby 1.9. Looks like it's trying to
build a version of the mysql gem that isn't compatible with ruby 1.9
(the other errors indicate that too) - i think ruby 1.9.1 needs 2.8.1
(http://rubyforge.org/frs/?group_id=4550)

Fred

Ok, I've followed the instructions and compiled, installed, and tested
successfully. However mysql is not showing up with the "gem list"
command.

john: gem list

*** LOCAL GEMS ***

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
rails (2.3.2)
rake (0.8.4)
rubygems-update (1.3.1)

Ok, I've followed the instructions and compiled, installed, and tested
successfully. However mysql is not showing up with the "gem list"
command.

Did you install rubygems yourself? It was my recollection that ruby
1.9 shipped with rubygems built in. Might you have crushed that by
installing it yourself ?

Fred

I believe I did install gems myself at some point. Although not after
installing 1.9.

john: find / -name gem
/usr/local/bin/gem
/usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem
/usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem

running

/usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem list
/usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem list

produce the same output. neither mention mysql. after running make
install on the mysql tar, that should have added it to the gems list
automatically? Is there another step I'm missing? Here's me
attempting to the latest version of mysql from the remote repository.

john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
gem list -r | grep mysql
activerecord-jdbcmysql-adapter (0.9.1)
dbd-mysql (0.4.2)
do_mysql (0.9.11)
jdbc-mysql (5.0.4)
motto-mysql (0.1.0)
mysql (2.7.3, 2.7)
mysql_replication_adapter (0.4.0)
mysql_retry_lost_connection (0.0.1)

john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
gem install mysql -v "2.7.3"
ERROR: could not find gem mysql locally or in a repository

I'm totally out of ideas. Is there a way I could clean all this up
and try again fresh? Thanks for the help thus far Fred.

I believe I did install gems myself at some point. Although not after
installing 1.9.

fine, just worried you might have installed a version of gem for 1.8
on top of the version of gem that came with 1.9

john: find / -name gem
/usr/local/bin/gem
/usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem
/usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem

running

/usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem list
/usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem list

produce the same output. neither mention mysql. after running make
install on the mysql tar, that should have added it to the gems list
automatically? Is there another step I'm missing? Here's me
attempting to the latest version of mysql from the remote repository.

make install on the mysql tar might have installed it not as a gem
(but there might be rake files in there for building it as a gem)

Fred

There is no rake file in the source directory. I think I'm about
ready to just give up on this problem. Maybe, upgrade my freebsd
system like i've been needing to for years and start using the ports
collection...

:(((((((

I think version.h disappeared in ruby 1.9. Looks like it's trying to
build a version of the mysql gem that isn't compatible with ruby 1.9
(the other errors indicate that too) - i think ruby 1.9.1 needs 2.8.1
(http://rubyforge.org/frs/?group_id=4550)

That's not building yet either, at least not for me:

cd /usr/src/mysql-ruby-2.8.1

make clean; make

gcc -I. -I/usr/local/include/ruby-1.9.1/i686-linux
-I/usr/local/include/ruby-1.9.1/ruby/backward
-I/usr/local/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET
-DHAVE_RB_STR_SET_LEN -DHAVE_MYSQL_MYSQL_H -I/usr/local/include
-D_FILE_OFFSET_BITS=64 -fPIC -O2 -g -Wall -Wno-parentheses -o
mysql.o -c mysql.c
gcc -shared -o mysql.so mysql.o -L. -L/usr/local/lib
-Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L.
-rdynamic -Wl,-export-dynamic -lmysqlclient -lpthread -lrt-ldl
-lcrypt -lm -lc
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql.so] Error 1

It doesn't find a packaged MySQL provided by my distro nor one
compiled from source by me.

I am having the exact same issue.
Any solutions yet?

There was just a discussion about this over on the railsforum website
and someone seems to have figured it out. Check it -
http://railsforum.com/viewtopic.php?pid=106007#p106007, or more directly
- http://nmanzi.com/?p=39.

cmyk wrote:

I am having the exact same issue.
Any solutions yet?

you need to install mysql client headers first, and then [since it's
ruby 1.9] you'll need a newer version than what the gem provides
either download 2.8.1 or a different gem
http://isitruby19.com/mysql
GL.
-r