Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i get IntelliJ to pick up my environment variables on MacOS X?

I have tried to set these using RCenvironment, .bashrc, .MacOSX/environment.plist and /etc/launchd.conf and restarted computer....IntelliJ is still not picking up my env variables:

Gemfile p "ENVIRONMENT: #{ENV['VAR_PRIVATE_GEM_USERNAME']}" # Outputs "ENVIRONMENT: "

like image 881
Kamilski81 Avatar asked Aug 01 '12 19:08

Kamilski81


People also ask

How do I access environment variables in IntelliJ?

Click edit configurations on the dropdown box for your runtime configurations. Select the runtime you want to add environment variables to. Click environment variables folder icon to pull up the environment variables screen.

Where are environment variables stored in MacOS?

app/Contents/Resources/app/bin/ in my case.


2 Answers

See the related questions:

  • https://apple.stackexchange.com/q/51677
  • https://apple.stackexchange.com/q/57385

Your question is not specific to IntelliJ IDEA at all.

On Mountain Lion solutions from the first link will not work, so you can do something like this in the Terminal:

export VAR_PRIVATE_GEM_USERNAME=John
open -a /Applications/IntelliJ\ IDEA\ 11.app/

Also note that many Run/Debug configurations in IntelliJ IDEA allow to set custom environment variables:

enter image description here

like image 178
CrazyCoder Avatar answered Oct 01 '22 20:10

CrazyCoder


You can set an environment variable on a Mac that will be available in all apps (not just the command line) by using "launchctl" (see https://ss64.com/osx/launchctl.html)

launchctl setenv VARIABLE_NAME VALUE
like image 25
fijiaaron Avatar answered Oct 02 '22 20:10

fijiaaron