I love Oh My Zsh, but it has never worked properly in the JetBrains product's Terminals:
- cannot find executables
- cannot use version managers like pyenv, sdkman, rvm
Oh My Zsh is zsh shell augmentation, so the actual problem could be reduced to just getting zsh to work properly. I have tried toggling all of the Terminal config options (individually and en masse) after reading some intellij issues, to an avail.
Try to uncomment first string in
~/.zshrc
:It helped me.
I can confirm everything in this answer, but there is a simpler workaround based on the fact, that loading
path_helper
twice doesn't matters.So until JetBrains fixes their Terminal plugin, just put
source /etc/zprofile
to your~/.zshrc
file and profit!Can't find binaries, can't run stuff? Obviously a $PATH problem, but what and why?
I echo'd a known good path in iTerm2
/Users/starver/.sdkman/candidates/maven/current/bin:/Users/starver/.sdkman/candidates/groovy/current/bin:/Users/starver/.sdkman/candidates/gradle/current/bin:/usr/local/Cellar/pyenv-virtualenv/1.1.3/shims:/Users/starver/.pyenv/shims:/Users/starver/.pyenv/bin:/Users/starver/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/X11/bin:/usr/local/git/bin:/Users/starver/bin/:/Users/starver/code/go/bin/:/Users/starver/.rvm/bin
and in IntelliJ:
This hints at a startup file loading problem. My zsh man page says the load order should be:
/etc/zshenv
$ZDOTDIR/.zshenv
/etc/zprofile
$ZDOTDIR/.zprofile
/etc/zshrc
$ZDOTDIR/.zshrc
/etc/zlogin
$ZDOTDIR/.zlogin
After adding an
echo
to each of those files that existed, I got the following for iTerm2:and this in IntelliJ
IntelliJ thinks this is not a login shell. In Jetbrains terminal configuration, you cannot enter
/bin/zsh --login
; it has no effect. After playing a bit, I found that turning on Tools -> Terminal -> Shell Integration makes the terminal a "login shell" and the startup file load story improved a bit:Notice that none of the global zsh startup files and this is the root problem:
/etc/zprofile
contains:which man path_helper explains:
Executing
path_helper
at least once during shell startup is REALLY important:paths
andpaths.d
are where the system and third party installers define their path additions. Not executing the system profile startup file is why/usr/local/bin
,/usr/local/go
, etc. are not on the path.I tried several approaches, looking for an elegant solution. Apparently, the jediterm terminal implementation prevents hooking into a standard terminal startup process - so they implement startup file loading in
/Applications/IntelliJ IDEA.app/Contents/plugins/terminal/.zshrc
. We can fix that implementation!! Replace that file with:Now, on IntelliJ terminal startup, I see
The first
/etc/zshrc
is executed before the plugin's.zshrc
, nothing I can do about that, and it is not causing any bad side effects...Repeat the process for every JetBrains product and you can have the joy that is Oh My Zsh everywhere.
Note: Issue reported to JetBrains in https://youtrack.jetbrains.com/issue/IDEA-194488.