Questions tagged [environment-variables]

Environment variables are used to create shared settings that persist between invocations of applications. They are used to provide information such as paths to important directories, user information and other information programs need for common tasks.

Environment variables are used to create shared settings that persist between invocations of applications. They are used to provide information such as paths to important directories, user information and other information programs need for common tasks.

101 questions
147
votes
11 answers

How do I set environment variables on OS X?

I have always difficulties setting the Environment variables in OS X like JAVA_HOME, M2_HOME or PATH. How to set these on OS X Mavericks? I did some research but the answers I've found didn't really help me yet: export JAVA_HOME=/... (But it seems…
akcasoy
  • 1,699
  • 2
  • 14
  • 14
135
votes
1 answer

ZSH: .zprofile, .zshrc, .zlogin - What goes where?

Now that I've upgraded to Catalina and I am using the new ZSH shell, I've noticed that ~/.bash_profile has been replaced with ~/.zprofile and since installing iTerm2 shell integration, it added a ~/.zshrc file. Looking at the ZSH documentation on…
Allan
  • 87,673
  • 27
  • 171
  • 374
75
votes
7 answers

How to add permanent environment variable in zsh

I have been scouring the internet, and cannot seem to find a solution to permanently adding an environment variable, specifically when my OS is macOS Mojave (10.14). It seems there are a lot of tutorials for past versions of the OS, but none for…
49
votes
5 answers

Where are system environment variables set in Mountain Lion?

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…
Felix
  • 829
  • 1
  • 7
  • 9
48
votes
8 answers

Setting the system-wide PATH environment variable in Mavericks

In previous OS versions one could set the system-wide PATH environment variable in /etc/launchd.conf to make it available for all apps (not just the command line). In Mavericks this appears to be no longer used. Is there another technique for doing…
Tom
  • 583
  • 1
  • 5
  • 6
43
votes
7 answers

How to add MySQL to $PATH variable to resolve "mysql: command not found"?

I installed MySQL on my Mac, and now I would like to add it to my $PATH variable. I want to be able to type mysql anywhere. I tried adding the following to my .profile file: export PATH=${PATH}/usr/local/mysql/bin/ I have restarted my Terminal but…
JNevens
  • 609
  • 2
  • 6
  • 9
41
votes
7 answers

How to set system-wide environment variables

We used to use /etc/environment to set system-wide environment variables on Mountain Lion. However, it seems this file is no longer read. Ideally the solution should apply to all users, and we need it to work with ssh console sessions. So we need…
joerick
  • 788
  • 1
  • 5
  • 11
20
votes
4 answers

How do I add a directory to PATH when using `zsh` in Sierra

In macOS Sierra 10.12.x, what is the modern way to add a directory to the PATH environment variable that can work across shells or specifically work with zsh shell (I switched from the default bash to zsh). I have seen some Questions and Answers…
Basil Bourque
  • 11,340
  • 36
  • 112
  • 185
16
votes
3 answers

In OSX Yosemite, why can I set many environment variables for GUI apps, but cannot set the specific variable PATH

After I had sorted out OSX' PATH issues up to the Mavericks release, the problems come back in Yosemite!!! So I want to mimic the old launch.conf feature in the new Mac OSX 10.10 Yosemite release, in order to have the PATH environment variable in…
halloleo
  • 1,230
  • 1
  • 13
  • 28
15
votes
1 answer

Unable to set DYLD_FALLBACK_LIBRARY_PATH in shell on OSX 10.11.1

In shell scripts used for unit testing with dynamic libraries in a directory other than the typical @rpath, I have previously been able to set DYLD_FALLBACK_LIBRARY_PATH to set the directory containing the libraries. Under 10.11.1, bash seems to…
14
votes
4 answers

How to change PATH environment variable to OS X 10.8 Mountain Lion that will be visible to GUI applications?

I tried all methods I heard of for setting environment variables on OS X 10.8 but none of them seems to work. To test, run a bash script from inside a gui application like Eclipse or IntelliJ IDEA. #!/bin/bash set|grep PATH Things I tested and that…
sorin
  • 28,475
  • 65
  • 162
  • 235
11
votes
1 answer

macOS Big Sur - set env vars for GUI apps?

I followed many methods on Ask Different as to how to change the $PATH environmental variable for GUI apps. Some of the methods may work for pre-Catalina macOS, some may work for Catalina, but none of them work for me on macOS Big Sur. So here's the…
Teddy C
  • 1,404
  • 2
  • 11
  • 30
10
votes
1 answer

Setting variables in environment.plist

I've been trying to come to terms with how to set environment variables needed by launched applications in Sierra, but I'm puzzled. Following various bits of advice found online, I created a file ~/Library/LaunchAgents/environment.plist. It looks…
Sean
  • 203
  • 2
  • 5
10
votes
2 answers

Set PATH variable so that it is detected in all applications, even outside terminal. (El Captain)

My ~/etc/path looks as follows: /usr/local/bin /usr/bin /bin /usr/sbin /sbin The Problem: When I type echo $PATH into terminal, I get back: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin And this persists for every application started in the…
FabulousGlobe
  • 103
  • 1
  • 5
9
votes
1 answer

How to use environment variables in applescript

I'd like to use my environment variables, which were defined in my environment.plist file, in my applescript. How do I do that, for instance: log "Glassfish Home: " & AS_HOME Where AS_HOME is my environment variable.
1
2 3 4 5 6 7