My project has a Ruby script that is run as a pre-build custom command. Part of that script involves running mercurial commands to get some information about the current changeset.
On a Windows machine, this is working fine. On my Mac OS X machine, it is not. The first line that executes a Mercurial command fails, and complains it can't find the file 'hg'. So I double-checked everything.
On my machine, mercurial is at /usr/local/bin/hg. In my terminal:
MyMachine:core owen$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Xamarin\ Studio.app/Contents/MacOS
If I run the prebuild script from the terminal, it works. When I launch from Xamarin Studio, it doesn't. So I added "puts
echo $PATH" to our script. Here's what the script thinks about $PATH when it runs:
/Library/Frameworks/Mono.framework/Commands:/Applications/Xamarin Studio.app/Contents/Resources:/Applications/Xamarin Studio.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
That is not my $PATH. I'm further confused, because $USER is my username, so it should be seeing my environment.
I've done some reading, and found bewildering information about launchctl and Environment.plist on OS X. It seems like they used to be used for applications not launched from the terminal, but are now obsolete. I can't find any information about what is the proper thing here.
But I need to get /usr/local/bin in $PATH in the environment in which my script executes. Yes, I can make a link to solve the problem right now. I don't want to make a link for every program I have in /usr/local/bin. That's why I have $PATH.