After configuring MacPorts, I was running into an issue on my Mac with Ruby on Rails where ‘/usr/bin/env ruby’ was giving me a different version of ruby than the one which has my gems installed. This was an issue for trying to run the ruby scripts with the shebang according to the best practices (i.e. /usr/bin/env ruby). So, trying to run script/console or script/server gave me lots of headaches. This may be a simple fix, but hopefully this will help others with similar issues.
$ /usr/bin/env ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10] $ /usr/bin/ruby -v ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
It took me a bit of fiddling and testing to figure it out, but I finally realized out that the MacPorts installation process had put its bin directories before the default bin directories. Ordering is fairly crucial – paths that are listed first take preference.
This is what I had after installing MacPorts:
This is the correct order (note – moved the /opt/local paths for MacPorts at the end to get things loaded in the right order):
With the order changed, now Ruby and Gem load from the same install (the MacPorts version of Ruby was loading overtop of the base Mac install).
Again, a simple fix, but hopefully, it might help someone running into the same issue.