In my Linux user .bashrc file for the user account I run under when doing Linux based development, I set an environment variable to let my apps know they are running in the development environment as opposed to running under the production environment:
LINUX_DEV=true
export LINUX_DEV # Make LINUX_DEV an environment variable
If I open a new Terminal window and run the following I do see the setting:
$>printenv | grep LINUX_DEV
$>LINUX_DEV=true
All is well. However, when I run WebStorm/IntelliJ, and use it's internal facility to launch a Terminal window, the environment variable can not be found:
$>printenv | grep LINUX_DEV
$>
If I execute the whoami command from either an external Terminal window or from the Terminal window launched by WebStorm, I get the exact same user name (my user name for the user account I run while on my local Linux box), so it's not a problem with different user accounts. I have already tried a full restart of my system to make sure it's not a transient issue. The problem persists.
Is WebStorm/IntelliJ running in some strange way that it can't access the environment variables set for the local user account? If the IDE was running as a background service or some other exotic executable context I could understand this, but as I said I launch it as a regular app under my user account and the whoami command shows the exact same user name as an external Terminal window does.
This is a real problem because when I try to use the Node.JS process.env variable and get the value of process.env.LINUX_DEV, that variable is undefined naturally due to this problem. How can I get this working properly?
NOTE: I did try putting the exact same environment variable setting in my /etc/environment file. I had to do a full restart to get WebStorm's Terminal window to see the changes but it did work. However, I would prefer to have the setting in my local user account so if anyone knows why I'm having this problem with setting it in .bashrc, I'd like to know.
UPDATE: Although the environment variable set in the /etc/environment file is visible from a WebStorm Terminal window, it is not visible via the Node.JS process.env variable so I'm still out of luck. I'm truly amazed that this is so difficult at this point.