nvm icon indicating copy to clipboard operation
nvm copied to clipboard

macOS: Webstorm, Intellij, all Jetbrains Products environment failure from nvm.sh after reboot

Open 0x-2a opened this issue 3 years ago • 9 comments

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!

Screen Shot 2022-03-23 at 9 26 14 AM

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.

0x-2a avatar Mar 23 '22 14:03 0x-2a

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?

ljharb avatar Mar 23 '22 16:03 ljharb

Yep -- and I imagine they'll respond similarly about nvm... c'est la vie

0x-2a avatar Mar 23 '22 19:03 0x-2a

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.

ljharb avatar Mar 23 '22 21:03 ljharb

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.

trespasserw avatar Apr 01 '22 14:04 trespasserw

How aggressive is the timeout inside a jetbrains terminal?

ljharb avatar Apr 01 '22 14:04 ljharb

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.

trespasserw avatar Apr 05 '22 07:04 trespasserw

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.

JohnAlbin avatar May 03 '22 06:05 JohnAlbin

Looking in the issue queue, this issue is probably a dupe of #2747 or #2724

JohnAlbin avatar May 03 '22 06:05 JohnAlbin

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.

trespasserw avatar May 09 '22 08:05 trespasserw