nvm
nvm copied to clipboard
macOS: Webstorm, Intellij, all Jetbrains Products environment failure from nvm.sh after reboot
For other users of Jetbrains products, I finally got to the bottom of this annoying message that seems to pop up only after full system reboot (before opening a terminal). After painstakingly going through every line of my .zprofile, .zshrc, .zshenv, commenting, uncommenting, rebooting, I found it... nvm.sh. Of course it's node related!
It seems something about nvm.sh (permissions, prompts, errors, etc) interferes with Jetbrains shell extension loader due to "interactive shell", see https://youtrack.jetbrains.com/articles/IDEA-A-19/Shell-Environment-Loading.
Trying to fix as suggested by Jetbrains doesn't work through...
# DOES NOT WORK
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # <--- problem
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi
I've got about 5 hours into finding this bug now -- hopefully someone who knows shell better than me can figure out what in nvm.sh is causing this issue. Reproduce with macOS 12.3, latest nvm freshly curled today, rm -rf node, yarn, all the symlinks, yadda yadda. Also posting on Youtrack so they can point others to comment out nvm.sh loads.
If it’s only happening inside JetBrains products, that suggests it’s not a node or nvm issue, but a jetbrains one. Have you reported it to them?
Yep -- and I imagine they'll respond similarly about nvm... c'est la vie
I’d hope not, given that they’re trying to emulate real terminals where it does work :-)
If there’s something i can do to work around the problem, I’m open to it, but i have no idea how to debug it since i don’t use that family of products.
A guy from JetBrains here 👋
Sorry, I have very vague understanding of how nvm.sh works, but most environment loading problems are caused by the command timing out. The question is whether the timeout is permanent (e.g. because of a tool invoked from a shell config file prompts for something) or intermittent (a tool just needs a little bit time). Given the mention of reboot in the issue, it looks rather like the second.
How aggressive is the timeout inside a jetbrains terminal?
At the moment, it is 20 seconds (hardcoded; will be tunable in 2022.1.1+). I have to add that a shell and the helper process are spawned early at the IDE start, which itself is a heavy task.
When I get this error (always after restart), I just quit JetBrains and restart it when my Mac has finished its login CPU churn. This is definitely a JetBrains issue, not a nvm one per se.
Looking in the issue queue, this issue is probably a dupe of #2747 or #2724
Well, in a sane world one wouldn't have to jump through hoops to get the environment.
The problem only happens after reboot, meaning it is a timeout situation - so faster nvm.sh startup would fix it; in this sense it is a duplicate.