I am using oh-my-zsh for my terminal. I have set IntelliJ to use /bin/zsh as the shell path. However no environment variable in my .zshrc file ever seems to get picked up. I'm defining environment variables like this (for instance):
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/mailcreds.json"But if I run:
echo $GOOGLE_APPLICATION_CREDENTIALSNothing comes up.
5 Answers
Set environment variables in ~/.profile instead of ~/.bashrc or ~/.zshrc, see this issue for details.
For me, the issue was that I load tmux automatically using .zshrc.
I followed the solution here:
Wrapped just the export ZSH_TMUX_AUTOSTART=true like this:
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then export ZSH_TMUX_AUTOSTART=true
fi 1 For Ubuntu, I edited my IDE desktop launcher to run zsh with login interactive:
- Go to
/usr/share/applications(where the desktop entry usually located or/var/lib/snapd/desktop/applicationsif you're using Snap). - Edit
jetbrains-idea.desktop(might be named differently). - Change
Execfield to include/bin/zsh -l -i -c "/opt/intellij/bin/idea.sh".
The final result of the file:
[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA Ultimate Edition
Icon=/opt/intellij/bin/idea.svg
Exec=/bin/zsh -l -i -c "/opt/intellij/bin/idea.sh" %f
Comment=Capable and Ergonomic IDE for JVM
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea
StartupNotify=true 1 Shared the same wrong behavior with Intellij in Manjaro (Arch), which uses zsh by default.
The issue comes with Flatpak, switching to Snap or downloading binaries directly from vendor's page got this solved.
Is similar to this issue (PyCharm): .
I solved it by opening Intellij using the terminal. You need to create Command Line Launcher if one doesn't exist.
- Go to
Tools->Create Command-line Launcher - Then choose the location you prefer
- Go to your terminal, and use that launcher command:
idea
This will open Intellij and start your app, this should be able to access your system environment properties.