On macOS, applications launched via a GUI (such as Finder, Dock, or Spotlight) inherit a relatively empty environment. Unfortunately, there’s no reliable or consistent way to modify this environment.
This has led to complaints where tools that work fine in a terminal do not work when launched from the IDE. To address this, JetBrains IDEs attempt to load the shell environment on startup.
To do this, the IDE starts a background shell process and instructs it to run a helper script. Since version 2021.2, the IDE shows a notification if this environment loading fails.
Why Shell environment loading fails
The most common cause is that a shell initialization script (e.g., .bashrc, .zshrc) tries to interact with a terminal.
The IDE uses the -i flag to launch the shell in interactive mode, because most environment modifications are placed in user *rc files — which typically assume they’re running in a terminal.
However, the shell launched by the IDE does not have access to a terminal, which can result in:
- Errors
- Hanging or timeouts (IDE has 20 second timeout to get shell environment) (For more detail, check the Locating IDE log files for the line: "can't get shell environment")
How to fix it
To avoid loading failures (and remove the notification), modify your shell script so it skips terminal interactions when launched by the IDE.
A common approach is to wrap such logic in a conditional block that checks for the IDE's environment variable:
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then...fi
This ensures the script behaves correctly when run by the IDE’s background shell, while continuing to work normally in the terminal.
The IDE has a 20-second timeout for running the helper script that retrieves the shell environment, and this timeout cannot be changed.
If any of your script parts take longer than 20 seconds, wrap those calls in a conditional block as well.
General Troubleshooting Steps:
- Open a terminal and run
echo $SHELL, or use any method to find your default shell. - Run
your_shell -i(e.g.,/bin/zsh -i,/bin/bash -i) in the terminal. - If it produces any errors or it takes too long to complete or waits for user input, check your shell initialization files and resolve these issues accordingly.
Additional Troubleshooting Steps for macOS
- In the IDE main menu, click
Help | Show Log in Finder, then open idea.log in a text editor. - Search for
EnvironmentUtil - loading shell envto locate a recent log entry similar to this:
2025-10-28 22:14:20,500 [ 19] INFO - #c.i.u.EnvironmentUtil - loading shell env: /path_to_your_shell -l -c '/path/to/IDE_Name.app/Contents/bin/printenv' > '/some_temp_path//ij-shell-env-data.tmp'
- If you see an error message like “can’t get shell environment” near that log entry, try to fix it.
- Copy the command part
/path_to_your_shell -l -c '/path/to/IDE_Name.app/Contents/bin/printenv'from your log. Add a backslash (\) before each space inside your actual'/path/to/IDE_Name.app/Contents/bin/printenv'to escape the spaces. - Open the Terminal app and run that command. If it produces any errors or it takes too long to complete or waits for user input, check your shell initialization files and resolve these issues accordingly.
Where to Find Shell Initialization Scripts
You can usually find your shell initialization script here:
-
~/.zshrcor~/.zshenv— if you’re using the default macOS shell (Zsh) -
~/.bash_profileor~/.bashrc— if you’re using Bash - Scripts under
~/.config/fish— if you’re using the Fish shell
If you can’t find any of these files, check your home directory (~) for similar configuration files.
Comments
0 comments
Please sign in to leave a comment.