nvm: big sur + zsh: `nvm_supports_source_options` is very slow

Operating system and version:

MacOS Big Sur version 11.0.1 (20B29)

nvm debug output:

with --no-use below is the output
nvm --version: v0.37.2
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8 (x86_64-apple-darwin20.0)'
uname -a: 'Darwin 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64'
checksum binary: 'shasum'
OS version: macOS 11.0.1 20B29
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Warning: Failed to set locale category LC_NUMERIC to en_IN.
Warning: Failed to set locale category LC_TIME to en_IN.
Warning: Failed to set locale category LC_COLLATE to en_IN.
Warning: Failed to set locale category LC_MONETARY to en_IN.
Warning: Failed to set locale category LC_MESSAGES to en_IN.
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin19.0.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/local/bin/git, git version 2.15.1
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20200816
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:279: command not found: npm
npm root -g: nvm:279: command not found: npm

nvm ls output:

        v8.15.1
       v10.16.0
       v10.18.0
       v10.21.0
default -> 10.21.0 (-> v10.21.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v10.21.0) (default)
stable -> 10.21 (-> v10.21.0) (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.22.1 (-> N/A)
lts/erbium -> v12.19.0 (-> N/A)

How did you install nvm?

Used to have nvm via brew. But removed it and used the install script after git clone

What steps did you perform?

  1. Opening a new ITerm2 window
  2. Opening a new ITerm2 tab

What happened?

Window/each tab opens very slow

What did you expect to happen?

Window/Tab opens faster (much faster)

Is there anything in any of your profile files that modifies the PATH?

I use .zshrc. It just loads .oh-my-zsh In my bash_profile.zsh in .oh-my-zsh, below is one change to PATH PATH="/usr/local/sbin:$PATH"

Below is out of profiling using zprof

Without --no-use while loading nvm

New iTerm2 window

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    1        5097.89  5097.89   82.35%   5097.89  5097.89   82.35%  nvm_supports_source_options
 2)    1         858.57   858.57   13.87%    298.37   298.37    4.82%  nvm_auto
 3)    2         560.20   280.10    9.05%    285.03   142.52    4.60%  nvm
 4)    1         186.51   186.51    3.01%    171.74   171.74    2.77%  nvm_ensure_version_installed
 5)    1          82.37    82.37    1.33%     82.37    82.37    1.33%  handle_completion_insecurities
 6)    4          61.38    15.35    0.99%     54.81    13.70    0.89%  nvm_npmrc_bad_news_bears
 7)    2          75.70    37.85    1.22%     54.69    27.35    0.88%  compinit

New tab

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    1        5090.09  5090.09   84.73%   5090.09  5090.09   84.73%  nvm_supports_source_options
 2)    2         493.81   246.90    8.22%    277.37   138.68    4.62%  nvm
 3)    1         763.55   763.55   12.71%    269.75   269.75    4.49%  nvm_auto
 4)    1         191.82   191.82    3.19%    176.35   176.35    2.94%  nvm_ensure_version_installed
 5)    2          71.90    35.95    1.20%     49.42    24.71    0.82%  compinit
 6)    1          27.22    27.22    0.45%     27.22    27.22    0.45%  handle_completion_insecurities
 7)    2          22.47    11.24    0.37%     22.47    11.24    0.37%  compaudit

With --no-use

New Window

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    1        5092.37  5092.37   96.67%   5092.37  5092.37   96.67%  nvm_supports_source_options
 2)    2          84.06    42.03    1.60%     51.88    25.94    0.98%  compinit
 3)    2          32.19    16.09    0.61%     32.19    16.09    0.61%  compaudit

New Tab

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    1        5090.18  5090.18   96.92%   5090.18  5090.18   96.92%  nvm_supports_source_options
 2)    2          75.79    37.90    1.44%     51.48    25.74    0.98%  compinit
 3)    1          26.25    26.25    0.50%     26.25    26.25    0.50%  handle_completion_insecurities

Please let me know if you need any further details. This slowness was conspicuous after Big Sur update. My doubt is same as this comment https://github.com/nvm-sh/nvm/issues/1978#issuecomment-452954807 about source not working fine

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 23 (9 by maintainers)

Commits related to this issue

Most upvoted comments

/sparkle @ljharb /sparkle @Nuru

Amazing support. Though this is purely zsh issue in my system, the proactive way you have fixed the code and removed the unnecessary things is praise worthy…

Thanks again.

Hmm, it seems you’re right that it seems to just ignore it; I wonder why I added it in the first place.

I’ll put up a PR to remove nvm_supports_source_options and see if that passes tests.

@anandncode While this is almost certainly a bug in zsh it would still be nice to find a workaround. What do you get from

time ((echo "echo 'hi there'") | (. /dev/stdin))

and this:

time (echo "echo 'hi there'" > /tmp/$$; . /tmp/$$; rm -f tmp/$$)

I’m not that familiar with zsh. What’s in your ~/.zshrc?

@ljharb My apologies for the delay. I was away. I don’t know why my zsh is taking so long. Do you have any suggestions on trouble shooting that i can do to figure out?

nvm_supports_source_options is doing virtually nothing - i can’t figure out why it’d be taking 5 seconds.

If it’s Big Sur to blame, the same thing should be happening on bash - and also, on zsh without omz. Could you try checking one or both of those variations?