# $PATH Search Order



## bodiddly (Jun 28, 2010)

Hey, I'm new to using a Mac (Just got my first Macbook last week), and am trying to get set up with Fink and MacPorts. I'm following the MacPorts installation instructions to get Metasploit Framework up and running and I'm having an issue setting the $PATH environment variable to search /opt/local/bin before /usr/bin.

I have edited the ~/.bash_profile as well as done a manual export of $PATH, and when I type "echo $PATH", terminal output is as follows:

/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin

From what I understand, the list is left to right as far as search preference. I used MacPorts to install ruby19 and confirmed the installation was successful, however when I "which ruby gem" in Terminal, I get:

/usr/bin/ruby
/usr/bin/gem

Is there anything I am missing or should check to set the preference to the /opt/local/bin directory?


----------



## ElDiabloConCaca (Jun 28, 2010)

For recently used PATH variables, bash will hit an internal hash table for the command and it's path.

You can view the hash table by typing "hash".

If the improper path is listed in the hash, type "hash -r" to clear the hash table.


----------



## bodiddly (Jun 29, 2010)

This fixed the issue. Thanks for your assistance!


----------

