Problems with Ruby Gems

This is driving me bonkers:

scott$ sudo gem install mysql

Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
ERROR:  While executing gem ... (NoMethodError)
    undefined method `cert_chain=' for #<Gem::Specification:0x714c34>


I've tried Googling but I get incosistent answers about what to do, and the error message here is nearly useless. Any suggestions?

And yes, I already ran this script. In fact, the problems started after doing so. I already have gcc 4.0 selected.


UPDATE: Okay, I got it working. Actually, there are a few different problems, and you have to do some running around to fix them all. First, this Gem::Secification issue is due to the fact that the script at tech.rufy.com/entry/46 grabs rubygems-0.8.10, which doesn't seem to work well. When I installed rubygems-0.8.11, that error went away. This script still has to be run to fix the other stuff, though!

Then there's the issue that the mysql gem needs to be reinstalled after running the fix script. By default, it won't find the mysql libraries. That's remedied with this (all on one line!):

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config


But this generates errors like this:


Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
Building native extensions.  This could take a while...
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'
mysql.c:637: error: 'res_free' undeclared (first use in this function)
mysql.c:637: error: (Each undeclared identifier is reported only once
mysql.c:637: error: for each function it appears in.)
make: *** [mysql.o] Error 1
mysql.c: In function 'query':
mysql.c:635: error: invalid storage class for function 'res_free'
mysql.c:637: error: 'res_free' undeclared (first use in this function)
mysql.c:637: error: (Each undeclared identifier is reported only once
mysql.c:637: error: for each function it appears in.)
make: *** [mysql.o] Error 1
ruby extconf.rb install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()... yes
checking for mysql.h... yes
creating Makefile



The solution is to switch to gcc 3.3 first:

sudo gcc_select 3.3
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config



Then switch back when you're done:

sudo gcc_select 4.0



To be fair, getting PHP running on Mac OS X was a bit tricky a few years ago too.
Design Element
Problems with Ruby Gems
Posted Oct 10, 2005 — 3 comments below




 

Cliff Hales — Oct 10, 05 425

Ah, I went through this a couple weeks ago, wasn't fun and in the end I'd tried so many different things that when it finally worked I wasn't even sure how I'd done it. Then I got a job at a web hosting company that offers rails and I haven't used my local install since. :-)

Tony Arnold — Oct 10, 05 426

http://www.tonyarnold.com/articles/2005/08/11/mysql-bindings-for-ruby-under-mac-os-x-tiger

Try that :)

Dale Gillard — Oct 11, 05 427

It'd be nice if we didn't have to go thru this at all. Given Ruby's installed with Mac OS X, and Apple's user base includes a lot of developers, I'd much prefer Apple install Ruby, Rails and a decent set of gems with Mac OS X.

I believe RubyGems is being integrated into Ruby 2.0 at the moment. So Mac OS X 10.5 will hopefully include all of these gems 'out of the box'.

But I certainly hope Apple do better supporting Ruby in 10.5 than they did with 10.4. Ruby's installed in a non-standard location, the readline module was missing (required for installing gems), and the author of the PDF::Writer module notes that images aren't rendered correctly because of Endian issues (Ruby in 10.4 was 'made' for Intel chips.)

I've sent Apple 'Mac OS X feedback' requesting better Ruby support in future Mac OS X releases and would encourage others to do so.




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.





Copyright © Scott Stevenson 2004-2015