Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:-

/opt/local/bin/

But when I run

which ruby

I get

/usr/bin/ruby

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.

add comment

2 Answers

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
add comment

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
add comment

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