coreybutler / nvm-windows

A node.js version management utility for Windows. Ironically written in Go.
MIT License
37.28k stars 3.32k forks source link

[Issue]: Loading NVM in Git Bash shell takes 10+ seconds #1103

Closed lashchev closed 7 months ago

lashchev commented 7 months ago

What happened?

Git Bash from Git for Windows 2.43.0.1 / Win 11

.bash_profile:

TIMEFORMAT='Starting NVM took %R seconds.'
time {
  export NVM_DIR="$HOME/.nvm"
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
}

Output on session start: Starting NVM took 10.343 seconds.

What did you expect to happen?

Start time should be sub-second

Version

1.1.11 or newer (Default)

Which version of Windows?

Windows 11+

Which locale?

None

Which shell are you running NVM4W in?

Other

User Permissions?

Standard Use, Non-Elevated

Is Developer Mode enabled?

No (Default)

Relevant log/console output

No response

Debug Output

Running NVM for Windows with administrator privileges.

Administrator: Command Prompt (Admin) - nvm  debug
Windows Version: 10.0 (Build 22631)

NVM4W Version:      1.1.12
NVM4W Path:         C:\Users\<user>\AppData\Roaming\nvm\nvm.exe
NVM4W Settings:     C:\Users\<user>\AppData\Roaming\nvm\settings.txt
NVM_HOME:           C:\Users\<user>\AppData\Roaming\nvm
NVM_SYMLINK:        C:\Program Files\nodejs
Node Installations: C:\Users\<user>\AppData\Roaming\nvm

Total Node.js Versions: 1
Active Node.js Version: v12.22.12

IPv6 is enabled. This can slow downloads significantly.

No problems detected.

Anything else?

No response

coreybutler commented 7 months ago

You've got the wrong project. Your code is measuring the startup time for nvm-sh. It even says so in the example code.

Furthermore, nvm-windows doesn't load anything because it's not a shim. When you call node/npm, you're calling node.exe directly. The only time nvm-windows does anything is when you run nvm <command>.

What I suspect you're doing is running nvm-sh in WSL. Perhaps that is trying to launch the WSL environment before it runs nvm... I really don't know. It looks like you ran nvm debug in the standard terminal... so technically you ran one program and produced debugging output for a different program.

I'm closing this because it looks like this is an nvm-sh issue or a WSL issue, not an nvm-windows issue.