Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to install ruby/rubygems on the latest version of 10.6. I used MacPorts to install ruby after noticing that my version was old. ruby was installed into /opt/local/bin.

I changed .bash_profile and added:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

When I echo $PATH, I get:

/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

So when I type which ruby I get:

/opt/local/bin/ruby

Which works correctly. However, when I type which gem I get:

/opt/local/bin/gem

When using gem -environment I get (gem is in the above directory):

-bash: /usr/bin/gem: No such file or directory

I'm completely open to uninstalling everything and starting over if necessary. I'm just not sure why it's still trying to grab it from /usr/bin!

share|improve this question

The default gem is a function and they get called before $PATH and also before the command hash.

Try playing with hash (or clearing it with hash -r ) to see if your path isn't getting a say in which gem to call.

type gem will confirm whether yur gem is really a function...

share|improve this answer
1  
To elaborate a bit: if an outdated hashed location is the issue, then hash -d gem will clear the entry for gem, after which the instance given by which gem should be the one that gets called. Opening a new bash instance should also clear the hashed commands. – PLL Apr 16 at 9:53

What a mess. I ended up removing all versions of ruby and MacPorts and compiling 1.9.2 from source. Everything is working fine now.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.