Josh M.
Josh M.

Reputation: 27791

IntelliJ IDEA does not see my environment variables

I've configured an environment variable in ~/.bashrc as well as ~/.profile.

When I run my application via IDEA's Gradle Configuration, my environment variable is apparently not available. E.g. I am referencing this variable within application.yml, but the default value is being used instead. Running Gradle from the command line correctly picks up my variable.

How can I configure IDEA to load this environment variable in a global way, so I don't have to manually add it to every project where I need it (~20 projects)?

Note: running on Manjaro Linux v18.

Upvotes: 14

Views: 13639

Answers (4)

Josh M.
Josh M.

Reputation: 27791

It turns out IDEA will pick up environment variables if you define them either in e.g. /etc/environment or /etc/profile or if you use ZSH, ~/.zshrc.

Upvotes: 12

Ashish Pani
Ashish Pani

Reputation: 1071

launchctl setenv HADOOP_VERSION 3.1.1.7.2.8.0-SNAPSHOT 

Execute in this way to set your environment variables in MacOS for them to be used by other applications. After that restart your IDE.

Upvotes: -1

Morteza
Morteza

Reputation: 662

After setting variables, you to execute source ~/.bashrc and source profile to update and execute the file contents.

Upvotes: 1

jccampanero
jccampanero

Reputation: 53411

@ josh-m I ran into the same problem in my IntelliJ IDEA setup with Maven.

In the end, I continued to keep the settings on each project, as there were not many, but when I studied the problem I found this IntelliJ support link:

https://youtrack.jetbrains.com/issue/IDEA-141832

At least at that time, this functionality was not available in IntelliJ directly, although the following plugin, mentioned in the comments of the support article, could perhaps be of some help:

https://plugins.jetbrains.com/plugin/7861-envfile/

Upvotes: 0

Related Questions