OS X: How to run a program with a specific PATH?
July 2, 2011 Leave a comment
The right answer to this challenge is to have different virtual machines with the complete environment. Unfortunately, due to crazy licensing issues, currently running Mac OS X as a virtual guest on a Mac OS X host is not allowed (according to some rumours, Lion will change this).
The next choice is to keep multiple versions of the development tools installed in different folders, but in this case extra care should be taken to avoid messing the PATH.
Once multiple version of the same tool are present in the filesystem, the safest way is to avoid adding any of them to the PATH, and start each tool with a specific PATH.
For example, we would like to start a certain version of Eclipse with a certain version of the cross toolchain:
export PATH=$PATH:/usr/local/CrossPack-AVR/bin $HOME/Developer/Eclipses/eclipse-3.6-cdt-m512/eclipse
One solution would be to create a script file and give it a name ending in .command. This makes the script clickable in Finder, but has the disadvantage of leaving a Terminal window around.
A very convenient solution is to use an AppleScript, and save it as an Application (.app).