Skip to content

[Issue]: Installing with a separate Admin account means that Path is not correct in PowerShell #1260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
justin-mellor opened this issue May 8, 2025 · 0 comments · May be fixed by #1261
Open

Comments

@justin-mellor
Copy link

What happened?

Installed using UAC with a different admin account

In PowerShell $env:PATH returned %NVM_HOME% and %NVM_SYMLINK% not the expanded variables. It sometimes worked in Command Prompt.

This is because the User Environment variables are created against a different user to current user, and NVM_HOME NVM_SYMLINK and Path are all REG_EXPAND_SZ so indeterminate which order they will be evaluated in.

This meant that nvm was not always found

What did you expect to happen?

$env:PATH should have included the actual install locations

Version

1.2.0 or newer (Default)

Which version of Windows?

Windows 11+ (Default)

Which locale?

English (Default)

Which shell are you running NVM4W in?

PowerShell

User Permissions?

Standard Use, Non-Elevated

Is Developer Mode enabled?

No (Default)

Relevant log/console output

PS C:\AzureDevOps\BottKitt\Deployment> $env:PATH
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\DiagnosticsHub\Collector;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\;C:\Program Files\PowerShell\7;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Cloudflare\Cloudflare WARP\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\160\Tools\Binn\;C:\Program Files\Microsoft SQL Server\160\Tools\Binn\;C:\Program Files\Microsoft SQL Server\160\DTS\Binn\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\PowerShell\7\;%NVM_HOME%;%NVM_SYMLINK%;C:\Users\Justin.Mellor\AppData\Local\Microsoft\WindowsApps;C:\Users\Justin.Mellor\.dotnet\tools;C:\Users\Justin.Mellor\AppData\Local\Programs\Git\cmd;;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\Linux\bin\ConnectionManagerExe

Debug Output

Justin.Mellor is not using admin or elevated rights.

Windows Version:        10.0 (Build 26100)

Windows Developer Mode: UNKNOWN

NVM4W Version:          1.2.2
NVM4W Author Bridge:    1.0.1
NVM4W Path:             C:\Users\Justin.Mellor\AppData\Local\nvm\nvm.exe
NVM4W Settings:         C:\Users\Justin.Mellor\AppData\Local\nvm\settings.txt
NVM_HOME:               C:\Users\Justin.Mellor\AppData\Local\nvm
NVM_SYMLINK:            C:\nvm4w\nodejs
Node Installations:     C:\Users\Justin.Mellor\AppData\Local\nvm
Default Architecture:   64-bit
Mirrors:                No mirrors configured
HTTP Proxy:             none

Total Node.js Versions: 1
Active Node.js Version: v20.17.0

IPv6 is enabled. This has been known to slow downloads significantly.

No problems detected.

⚠️  NVM for Windows will eventually be succeeded by Author/Runtime


Find help at https://github.com/coreybutler/nvm-windows/wiki/Common-Issues

Anything else?

The problem comes because the installer uses RegWriteExpandStringValue() for NVM_HOME and NVM_SYMLINK. It should be using RegWriteStringValue() because these variables do not need to use expansion. This ensures that Path can expand the values as it will be evaluated after.
I have a PR for a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant