Edit the command line path for an executable on OSX

1

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.

Stu

Posted 2012-09-03T13:38:07.083

Reputation: 21

Question was closed 2012-09-03T14:22:40.007

Answers

3

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

Ansgar Wiechers

Posted 2012-09-03T13:38:07.083

Reputation: 4 860

1

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.

TheMonkeyMan

Posted 2012-09-03T13:38:07.083

Reputation: 107