Editing the /etc/launchd.conf file in OS X

I am trying to run Android project using Maven in Mac 10.7.4, for that I need to set environment and path variables.

This are the steps I need to follow to run android using Maven

Maven 3.0.3+ installed,

Set environment variable ANDROID_HOME to the path of your installed Android SDK and add $ANDROID_HOME/tools as well as $ANDROID_HOME/platform-tools to your $PATH. (or on Windows %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools).

MacOS users: Note that for the path to work on the commandline and in IDE's started by launchd you have to set it in /etc/launchd.conf and NOT in .bashrc or something else

But I am very new to OS X so I don't know how to set it. I seen this post but I get stuck in Step 4, saving the etc/launchd.conf file after entering the paths.

  • How do I set environment variables globally?

  • What do I need to open, edit, save the etc/launchd.conf file?


Do you actually need system-wide variables? If variables in your user environment would suffice you could create a directory ~/.MacOSX and a file environment.plist in it, in case one of them doesn't exist, and then add your variables to environment.plist.

mkdir ~/.MacOSX
touch ~/.MacOSX/environment.plist
open ~/.MacOSX/environment.plist

Log off and back on for the changes to become active.


You can use any editor to change the /etc/launchd.conf file, you don't have to use vi or vim.

Since you need superuser privileges to edit the file, you cannot simply run TextEdit. What you can do however is to open a Terminal and enter:

sudo touch /etc/launchd.conf
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/launchd.conf

Now, TextEdit will open /etc/launchd.conf. Make your changes as explained in this Stack Overflow answer you mentioned. Make sure to replace the highlighted part with the actual path to your Android SDK, also changing your username.

setenv ANDROID_HOME /Users/your-username/Documents/android-sdk/

Now save the file as usual through File » Save or CmdS.

A reboot might be necessary.


You could also just open terminal and type launchctl

then setenv <key> <value>

which in your case woud be setenv ANDROID_HOME /path/to/whatever