2

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?

Josh M.
  • 26,437
  • 24
  • 119
  • 200
  • Possible duplicate of [IntelliJ IDEA global environment variable configuration](https://stackoverflow.com/q/45696203/608639), [Use Environment Variables in IntelliJ IDEA Bash Script](https://stackoverflow.com/q/43815802/608639) – jww May 31 '19 at 13:02
  • I've tried that (placing them in `~/.profile` and `~/.bashrc`) and they are still not exposed to IDEA even after logging out / rebooting. – Josh M. May 31 '19 at 18:19
  • 1
    Your X11 programs are typically started by your X window manager, which is typically started by xsession, which typically reads your ~/.xsessionrc, but who knows really how it works on your system. – n. m. could be an AI Jun 02 '19 at 03:16
  • @n.m. -- thanks, I'm running Manjaro with KDE Plasma FWIW. – Josh M. Jun 03 '19 at 13:37

1 Answers1

1

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).

Dodo
  • 156
  • 2
  • 14