Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

Possible Duplicate:
What are PATH and other environment variables, and how can I set or use them?

I have the default package of Ruby installed that shipped with the OS, which is an older version.

I have recently installed MacPorts with the latest Ruby version which is installed in a seperate location:-


But when I run

which ruby

I get


Is there any way to edit the path of the command ruby so it would reference the new installation in the /opt/ directory?

Thanks in advance.

share|improve this question

marked as duplicate by slhck Sep 3 '12 at 14:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You have to put /opt/local/bin before /usr/bin in your $PATH and maybe clear your command cache with hash -r.

share|improve this answer

Well since Mac is based on Unix its a simple command Editing your config file.

you can try that

~/.bash_profile (Local Profile) or
~/.MacOSX/environment.plist (System Wide)
export PATH=/opt/local/bin:$PATH

or you can use an alias however the which command wont work with these.

alias ruby=/opt/local/bin/ruby 

Hope this helps, Here is a link for more information effectively you are looking to set an environment variable.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .