Forum Visual Studio


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How do I control the $PATH used by Xamarin Studio on OSX Yosemite?

OwenPOwenP USMember ✭✭

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

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:


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.

Best Answer


  • OwenPOwenP USMember ✭✭

    In this case, it's just a custom command that executes a Ruby script. RE: the list of solutions:

    1. That's a bit clunky, but something I could consider.
    2. This is what I'm doing right now.
    3. I can't hard-code a path because we have a variety of development machines, some are Windows, and as sure as there's a sun out today I bet no one has a consistent path to the tool.
    4. I can't make symlinks in /usr/bin, because OS X protects this directory unless I turn off some security features.

    Most of these feel really janky because of #4. If OS X supported making symlinks in these directories, I'd not have even posted because I'd expect Mercurial to have done the same thing. I'm moving on with my solution via #2, but it's frustrating to find $PATH won't work. It's one of the few consistent cross-platform configuration variables.

  • JoelHolmbergJoelHolmberg SEMember

    I face the exact same issue. OwenP could you let me in on how you set the PATH variable that Xamarin uses in your pre-build custom command?

Sign In or Register to comment.