In Lion (and previous releases) it was in .MacOSX/environment.plist. After upgrading to 10.8, the file is still there, but the variables aren’t taking.

I’ve also tried adding them to /etc/launchd.conf and they’ll show up in Terminal, but not GUI applications (like my IDE).

  • Did you reboot after changing /etc/launchd.conf?
    – nohillside
    Commented Jul 25, 2012 at 17:16
  • I did, and all the variables therein are now available in any terminal, but not present for my IDE.
    – Felix
    Commented Jul 25, 2012 at 17:26
  • Maybe the IDE does not expose the environment to you (See my answer)? What IDE is it? is it launch directly by the Finder or Spotlight?
    – halloleo
    Commented Apr 15, 2013 at 23:32

5 Answers 5


I know this is an old question but I thought I would point out that in Yosemite /etc/launchd.conf no longer works (as confirmed by the man page). So here is an alternative.

Launch AppleScript Editor, enter a command like this:

do shell script "launchctl setenv variablename value"

(add as many lines as you like)

Now save (⌘S) as File format: Application. Finally open System SettingsUsers & GroupsLogin Items and add your new application.

  • Note that it might nor work with other apps that are opened as Login items and perhaps those you open quickly after login
    – mmmmmm
    Commented Sep 20, 2014 at 17:04
  • This worked for me. Thank you so much. This has been driving crazy all day!
    – wholladay
    Commented Oct 22, 2014 at 2:06
  • 2
    Looks like the only real&universal solution so far. But it needs 9 more upvotes to go up and become first answer. :c Commented Feb 17, 2015 at 18:41
  • This worked for me on El Capitan. As noted above by @Mark, there are issues with ordering (eg. resumed applications may or may not have the environment), but once logged in this works as you would expect. That is, applications started from Spotlight or the Dock have the correct environment. Commented Mar 2, 2016 at 23:49
  • @Mark You can try this answer, making use of the Launch Agent. In my case the Launch Agent starts after the Login Items, so I move the target application (like Eclipse) from Login Item to Launch Agent, so that they will be started after this special application setting environment variables. Commented May 22, 2017 at 5:08

I asked this question on the Apple Developer Forums as well and got back this, official response.

Change the Info.plist of the .app itself to contain an "LSEnvironment" dictionary with the environment variables you want.
~/.MacOSX/environment.plist is no longer supported.

  • 3
    Where is that located?
    – orome
    Commented Dec 12, 2012 at 19:10
  • 1
    It would be useful to provide a link to a more specific example. Commented Feb 2, 2013 at 4:41
  • 1
    Update: I tried changing that file, after figuring out the syntax (I think), but it does not work at all for me. Commented Feb 2, 2013 at 5:04
  • 4
    There will be an Info.plist per application in WhatEver.app/Content/Info.plist. You can edit it with XCode. Click the "+" on the Information Property List and add a dictionary called LSEnvironment. If you type it correctly it will rename it to Environment variables. Then you click the "+" by that for each environment variable you want to add.
    – Felix
    Commented Feb 6, 2013 at 1:28
  • 2
    This is a nice solution, but it no longer works as of Yosemite 10.10.5.
    – Dalmazio
    Commented Oct 28, 2015 at 18:13

As you have discovered, the use of environment.plist file is no longer followed, the variables stored in Info.plist as LSEnvironment strings are only set by launchd.

You cannot depend on them to set a general environment variable that the terminal will set if you call your program from the terminal/shell directly. The good news is the open -a command does trigger launchd to do the launching, so the variables will be set consistently for the app environment if not for the local shell environment.


Setting environment variables in /etc/launchd.conf is the way to go: Every application launched after a reboot by local shells, Finder or Spotlight inherits these variables - I have tested this extensively with Mountain Lion 10.8.3.

2 caveats:


Try launchctl setenv NAME VALUE. I don't know if/what it does differently from editing launchd.conf, but it works for me in both Terminal and GUI apps. More details.

Note this doesn't survive across a reboot. Here's a way to fix that.

  • 3
    That's quite a long page you are linking to here. Where exactly is the relevant part? Could you include it directly into your answer to make it easier for everybody?
    – nohillside
    Commented Mar 17, 2013 at 8:24
  • 2
    oops, good point, thought i'd included more of a fragment in that url. fixed.
    – ryan
    Commented Mar 18, 2013 at 14:30
  • 1
    The way to survive across a reboot given there uses the environment.plist which stopped working under Lion
    – mmmmmm
    Commented Sep 20, 2014 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .