44

Yosemite /etc/launchd.conf is no longer supported in 10.10. See man launchctl: The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations. You can now for example save this plist as ~/Library/LaunchAgents/my.startup.plist: <?xml version="1.0" encoding="...


36

Here is why your current code is not working: export PATH=${PATH}/usr/local/mysql/bin/ You forgot the colon. export PATH=${PATH}:/usr/local/mysql/bin/ is the correct code.


34

I have a .profile in my home directory; it contains many export … statements for environment variables. You can create such a file by opening a Terminal and issuing the command touch .profile Close Terminal. Then you should open that file in a plain-text editor (TextWrangler for example). You can also use nano .profile in a Terminal window (current ...


21

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. ...


21

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.


21

In Yosemite, you should put export VARIABLE='something' inside .bash_profile. I've tried writing the export VARIABLE='something' inside .profile without success.


17

Try adding the following line to your .bash_profile file. export PATH="/usr/local/mysql/bin:$PATH" You can do this easily with the following command, which will append the line if the file already exists or create a new file with the line if it doesn't. echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile


16

The correct file, prior to Mavericks, was ~/.MacOSX/environment.plist. This is no longer supported. In Darwin, and therefore in Mac OS X, the proper place to set these is in /etc/launchd.conf to apply to all processes; if relating to user shells specifically, use the appropriate shell files instead, depending on the shell in question. See the launchd.conf ...


14

After many trials with different options I conclude: Is there a unified way to set the PATH for applications launched by different means (like shell script, Finder and Spotlight)? Well, yes and no: No: Setting PATH in shell start up scripts (e.g. .bashrc) works only for apps launched by shells. No: Setting PATH for the current launchd process via launchctl ...


12

There is a much easier way. Place a text file in the folder /etc/paths.d/. In this text file, enter the desired path AND a newline. The best way is to create a new file for each path. On my system, there is a file called MySQL with the text '/usr/local/mysql/bin' and a newline.


10

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 ...


9

If you are using bash, then setting the environment variables in /etc/profile will apply for all users. From the bash manual on OS X Mavericks, with my emphasis (this has not changed from previous versions): When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands ...


8

With Mountain Lion /etc/launchd.conf is where you should set the GUI applications Path. Remember it's not a script file; it only supports launchctl commands so you should write something like: setenv PATH /new/path:/usr/bin:/bin:/usr/sbin:/sbin Note also that it doesn't support shell environment variable substitutions (like $PATH) so you'll have to set ...


8

Try this: log "Glassfish Home: " & (system attribute "AS_HOME")


8

This is System Integrity Protection introduced in El Capitan Documentation is in this from Apple Basically any Apple supplied OS X executables are protected. and (from an earlier document) Spawning children processes of processes restricted by System Integrity Protection, such as by launching a helper process in a bundle with NSTask or calling the exec(...


8

The loginwindow process sets a user's environment. It sets the variables TMPDIR and PATH, consults Directory Services and sets SHELL HOME USER LOGNAME . PATH is set to /usr/bin:/bin:/usr/sbin:/sbin unless modified by launchd (in the more current versions of OS X). This is the PATH variable available to the user's processes unless modified by that particular ...


7

For those who don't like to have the hassle with text files and editors, there is a GUI tool as well on GitHub.


7

From http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac: Open Terminal Run touch ~/.bash_profile; open ~/.bash_profile In TextEdit, add export PATH="$HOME/.rbenv/bin:$PATH" Save the .bash_profile file and Quit (Command + Q) Text Edit. Run source ~/.bash_profile


6

If you look in your console, you'll probably see a message about sandboxd preventing gs from running. Just add this line to the end of /etc/cups/cups-files.conf: Sandboxing Relaxed then type: sudo launchctl stop org.cups.cupsd


6

I'm going to lump together 1 & 2 because all shells read files at startup. PATH is inherited from its parent process. This is a key concept that you need to understand. The PATH is first hard coded into the kernel: sysctl user.cs_path user.cs_path: /usr/bin:/bin:/usr/sbin:/sbin launchd which acts as init can be configured to change this PATH. ...


6

You need to explicitly start an interactive bash shell at the end of your script in order to keep the window open when you open the .command file from Finder. The following revision of your script demonstrates that and also streamlines other aspects of your code: #!/bin/bash # Note: $PATH already exists as an exported variable, assigning to it # ...


5

In bash (the default shell of Terminal on 10.8) the syntax: HOME=/your/path export HOME


5

For adding a directory to a path, there is a better option in OS X: All entries in the file /etc/paths are added to the path, before any shell is started. Edit this file with: sudo pico /etc/paths For more info, see: https://gist.github.com/Overbryd/1669348


5

What you (and anyone else finding this question) are almost certainly looking for is the following path: /private/etc/paths You can always put your edits into the /private/etc/paths.d if you want to avoid changing the main system default "paths" configuration document, but then they will be appended to the end of your $PATH variable, so if you want to add ...


5

You can accomplish this by going to your .bash_profile file and adding these lines to it. alias mysql.start="sudo /usr/local/mysql/support-files/mysql.server start" alias mysql.stop="sudo /usr/local/mysql/support-files/mysql.server stop" alias mysql.restart="sudo /usr/local/mysql/support-files/mysql.server restart" alias mysql.status="sudo /usr/local/mysql/...


5

The old path is still cached by the shell. Either open a new tab/window or run hash -r to clear it.


4

For the sake of clarity, I will refer to this solution as the static solution, the second solution as the dynamic solution, and finally this one as the launch agent solution. I am going to compare the static and dynamic solution with the launch agent one, respectively. The static solution involves the editing of /etc/launchd.conf. This has the advantage, as ...


4

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: Shells might overwrite the settings in their login scripts. (See For correct functioning in shells though...) ...


4

OSX has had only one change re environment variables and that was in Lion where ~/.MacOSX/environment.plist was removed. Although there also has been a change in the default shell in 10.2 or 10.3 from tsch to bash. You need to define what you want the enviroment variable set for and what environment you have. You also need to understand shells and Unix ...


4

Just for the sake of anyone who might come along and wonder how to restrict this to only when the TERM is a certain value, you could put something like this in your shell's "rc" file (.zshrc or .bashrc etc): case "$TERM" in xterm-256color) export CLICOLOR="YES" ;; *color|xterm*) export CLICOLOR="YES" ;; vt100) ...


Only top voted, non community-wiki answers of a minimum length are eligible