Installing RubyGems with MacPorts

Posted on in Programming

IM_OK (photo by danzo08)Quick note.

I recently needed to install a few RubyGems on my Mac OS X 10.4 (Tiger) development system. I use MacPorts to keep my system consistent, but MacPorts was causing the problem. Here's a look at the output I was getting while trying to install Active Support.

$ sudo port install rb-activesupport
--->  Staging rb-activesupport into destroot
Error: Target org.macports.destroot returned: shell command "/opt/local/bin/gem install --local --force --install-dir /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_ruby_rb-activesupport/work/destroot/opt/local/lib/ruby/gems/1.8 /opt/local/var/macports/distfiles/ruby/activesupport-1.4.2" returned error 1
Command output: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- sources (LoadError)
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/source_info_cache.rb:6
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:12
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:112:in `manage_gems'
        from /opt/local/bin/gem:10

Error: Status 1 encountered during processing.

Definitely not good. I stumbled across the solution to my problem on the MacPorts bug tracking system. For those suffering through the same issue, run the following commands once and you'll be fixed up.

cd /opt/local/lib/ruby/gems/
export RUBYLIB=$PWD/gems/sources-0.0.1/lib
sudo gem install cache/sources-0.0.1.gem
unset RUBYLIB

Hopefully that will save you some time. Happy programming!

My Bookshelf

Reading Now

Other Stuff