Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 262
Josh M. Avatar asked Feb 12 '19 19:02

Josh M.


People also ask

How do I see 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.

How do I enable environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

Do we need to set environment variables for IntelliJ?

Add environment variables to an application In order to compile the project, you must also set the module to classify the location of classes and packages.

How do I install .ENV files in IntelliJ?

Open settings, then select plugins In the search box search for “. env files support” and install it. After restarting IntelliJ you will have a new tab in the Run Configurations screen called EnvFile.


1 Answers

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

like image 59
Josh M. Avatar answered Oct 24 '22 16:10

Josh M.