52

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


46

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


38

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.


26

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


22

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

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


20

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


18

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


14

Bash Since Bash is typically the default shell you can open up this file in your home directory: $ vim ~/.bash_profile And add your variable to this file: export ENV_VAR=12345 You can do this without even having to edit this file if you like, using the following one-liner: $ echo 'export ENV_VAR=12345' >> ~/.bash_profile And then confirm like so:...


11

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

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


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


10

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


10

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

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

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


7

This answer (to a different question) suggests modifying /private/etc/paths or adding a file to the directory /private/etc/paths/d. I just tried sudo nano /private/etc/paths, added /foo at the end of the file, and opened a new tab in Terminal, and echo $PATH showed /foo as expected, in both bash and zsh shells. Assuming you've installed Maven to /opt/apache-...


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

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


5

From the man page for PATH (man path): The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below)....The default path is system-dependent, and is set by the administrator who installs bash. A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''....


5

The /etc/profile file, which Bash executes for login shells, includes the following content: # System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi It's the path_helper program that sets up the PATH environment ...


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