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 Jul 25 '12 at 17:16
  • I did, and all the variables therein are now available in any terminal, but not present for my IDE. – Felix Jul 25 '12 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 Apr 15 '13 at 23:32

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 Dec 12 '12 at 19:10
  • 1
    It would be useful to provide a link to a more specific example. – Blaisorblade Feb 2 '13 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. – Blaisorblade Feb 2 '13 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 Feb 6 '13 at 1:28
  • 2
    This is a nice solution, but it no longer works as of Yosemite 10.10.5. – Dalmazio Oct 28 '15 at 18:13

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 Sep 20 '14 at 17:04
  • This worked for me. Thank you so much. This has been driving crazy all day! – wholladay Oct 22 '14 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 – Display Name Feb 17 '15 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. – Alec Thomas Mar 2 '16 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. – Franklin Yu May 22 '17 at 5:08

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 Mar 17 '13 at 8:24
  • 2
    oops, good point, thought i'd included more of a fragment in that url. fixed. – ryan Mar 18 '13 at 14:30
  • 1
    The way to survive across a reboot given there uses the environment.plist which stopped working under Lion – mmmmmm Sep 20 '14 at 17:06

You must log in to answer this question.

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