Thursday, July 30, 2009

Multiple versions of ruby can cause confusing errors

Probably a big "well, duh" moment for those more *nix experienced than me, but perhaps it will help some anyway.

So we upgraded ruby and rubygems on a machine last night, and after doing so found that a Rails script called by cron could no longer find the mysql gem. No problem I thought, I'll just reinstall it... but then "gem install mysql" reports an error:

/usr/local/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***

Poo. Google quickly solves this issue:

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

mysql gem installs without a hitch, happy again! So let's run the script: KABOOM.

custom_require.rb:36:in `gem_original_require': no such file to load -- mysql (MissingSourceFile)

WTF? I just installed it?! Let's see, "gem list" shows it, irb can require it, ./script/console can retrieve records... what's going on?

Check the cron command again: hmm, we're calling /usr/bin/ruby.

ruby -v
reports 1.8.7, but
/usr/bin/ruby -v
reports 1.8.5.
which ruby
tells us /usr/local/bin/ruby. Let's try this:
mv /usr/bin/ruby /usr/bin/ruby-1.8.5
ln -s /usr/local/bin/ruby /usr/bin/ruby

Cross fingers, try our cron script again, this time it works!

Tuesday, July 28, 2009

Google Voice Comedy Gold!

Well, maybe comedy tin, or perhaps nickel. I've gotten a Google Voice account, and I picked a number which I thought would be "cool"... a number that is a pretty common progression on the number pad. It turns out this number is frequently dialed by... toddlers discovering the telephone! So now I'm growing a library of voicemails from three-year-olds saying "Hello? Hello? Daddy?" and the like. Took me about two calls to realize this and subsequently turn off the call forwarding to my real phone. I'll probably just keep the account for its novelty value for the time being.