Leopard and Bash Shell environment paths

If you recently made the upgrade to Leopard and you’re a frequent user of the OSX Terminal application, you may find that the environment paths that you had set up for the bash shell no longer work. Previously in Tiger, one can easily define those paths by creating a .bash_profile or .profile configuration file in the user directory, or editing the system-wide configuration file /etc/.profile directly if you have root access.

While I personally have never been able to make the configuration files work in the user directory, I’ve had success setting my environment paths in /etc/.profile. However, along with many other components that got shuffled around in the latest release of OSX, those profile settings are no longer found in the same locations. Oh why o why, Apple?


In Leopard, the road to setting environment paths is a rather convoluted one. I wish Apple had made it easier but to date, I haven’t come across any other simpler solution. Here are the few steps that I took to resolve the issue:

  1. If you open /etc/.profile in a text editor, you’d see that the Terminal now loads the environment paths via a configuration file in /usr/libexec/path_helper.
  2. Opening the path_helper file reveals that environment paths are now collectively stored in a file aptly named paths in the etc directory. Open /etc/paths and you’d see that all the environment paths are neatly listed here. You can simply add your desired paths such as /usr/local/mysql/bin to this list.
  3. Relaunch the Terminal and test.

Please note that root user needs to be enabled in order for you to edit the /etc/paths file. To enable the root user, see this article.

Addendum

Good news! Since writing this tutorial I had successfully implemented a .bash_profile file to my shell, effectively rendering the above procedure unnecessary. The secret is in applying the Unix source command which is built into the shell. Create your .bash_profile document at the root of your home directory as follows:

export PATH=”/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/mtasc:/usr/local/tomcat/bin:$PATH”

and add any relevant paths that you may need. Then execute source .bash_profile in the command line. This ensures that changes to the environment made in .bash_profile are registered before you restart the shell.

Share/Save/Bookmark

4 Responses to “Leopard and Bash Shell environment paths”

  1. Richard Fox Says:

    Many thanks, had never figured this out before under Tiger, but your article showed exactly what I needed to do in Leopard.

  2. Mufasa Says:

    Thanks for the tip! Glad this is the second hit on a “osx leopard shell bash path” Google search. It was exactly what I was looking for! ;-)

  3. Lorin Rivers Says:

    Not sure what is causing your issues, but creating ~/.profile works great for me. I have tons of PATH bits in mine.

  4. Adriano de la Cruz Says:

    In addition to editing /etc/paths , you can also create files in the /etc/paths.d/ folder (one foldername per line). path_helper will process each file the same way as it processes /etc/paths. This can make it easier to organize your paths (i.e. by third-party application, by project, etc); I added a file “MySQL”, which simply contains “/usr/local/mysql/bin”.

    The files in /etc/paths.d are processed alphanumerically, so if you need the folders in a specific file to take precedence in the path list, name the file accordingly (i.e. “0001-mysql” instead of “mysql”, to process it before “custom_app”).

Leave a Reply