Search code examples
linuxintellij-ideaenvironment-variables

Definitive answer on where to put environment variables so IntelliJ IDEA will pick them up?


Using IntelliJ IDEA (v2019.1.2 Ultimate on Manjaro Linux), I need to be able to "inject" some environment variables into the IDE on startup. For instance, all of my projects need to know the host name of the MYSQL server to use, e.g. MYSQL_HOST. I have exported this and other variables in /etc/bash.bashrc as well as ~/.profile and ~/.bashrc but IDEA does not seem to pick up these variables from any of those locations even after logging out / rebooting.

I am not interested in setting these environment variables for each and every project / run configuration manually. I need to set them once, globally, and have them apply everywhere.

However, to illustrate what I mean, IDEA does list the "system" environment variables that it has loaded in the Run/Debug Configuration > Environment Variables window:

Environment Variables

My specific env vars are not listed here, and I'm not sure from whence the listed vars came.

Where should I enter environment variables so they will be picked up by IntelliJ IDEA?


Solution

  • For me it worked when I add the variable to /etc/environment. After new login to system (not just restarting IntelliJ) I finally found the variable listed at system environment variables table in my run configurations.

    My IntelliJ IDEA version: 2022.2.2 (Ultimate Edition). My OS: Debian 11.4 (bullseye).