There are a lot of moving parts in a Rails development environment these days. RVM helps us develop with exactly the version of Ruby on the production server, and allows us to keep up with the proper gemsets for each project as well. However, getting all the versions to play properly together can be a trial.
This morning we ran into some trouble installing the MySQL gem version 2.7 for a project using Ruby Enterprise Edition (REE) version 1.8.7-2011.03. The error looked like this:
ree-1.8.7@global $ env ARCHFLAGS="-arch x86_64" gem install mysql -v 2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: While executing gem ... (TypeError)
can't dup NilClass
Searching the error didn’t provide much help, because the relevant keywords turn up all over the place, but eventually I found a page suggesting that versions of rubygems might be the issue. (More specifically, that some gems don’t play well with some versions of the rubygems binary.)
At this point I went to the #rvm IRC channel, where “telemachus” put me on track for how to change versions of rubygems within each RVM environment. So I tried downgrading from 1.6.2 to 1.5.2:
ree-1.8.7@global $ gem --version 1.6.2 ree-1.8.7@global $ rvm rubygems 1.5.2 Removing old Rubygems files... Installing rubygems dedicated to ree-1.8.7-2011.03... Installing rubygems for /Users/parker/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby Installation of rubygems completed successfully. ree-1.8.7@global $ gem --version 1.5.2
And that let me install the MySQL gem successfully:
ree-1.8.7@global $ env ARCHFLAGS="-arch x86_64" gem install mysql -v 2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.7 1 gem installed Installing ri documentation for mysql-2.7... Installing RDoc documentation for mysql-2.7...