Skip to content
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

nvm root elevate.cmd: file does not exist #505

Open
6 of 20 tasks
Poltergeisen opened this issue Jan 27, 2020 · 21 comments
Open
6 of 20 tasks

nvm root elevate.cmd: file does not exist #505

Poltergeisen opened this issue Jan 27, 2020 · 21 comments

Comments

@Poltergeisen
Copy link

My Environment

  • Windows 7 or below (not truly supported due to EOL - see wiki for details)

  • Windows 8

  • Windows 8.1

  • Windows 10

  • Windows 10 IoT Core

  • Windows Server 2012

  • Windows Server 2012 R2

  • Windows Server 2016

  • My Windows installation is non-English.

I'm using NVM4W version:

1.1.7

I have already...

  • read the README to be aware of npm gotchas & antivirus issues.
  • reviewed the wiki to make sure my issue hasn't already been resolved.
  • verified I'm using an account with administrative privileges.
  • searched the issues (open and closed) to make sure this isn't a duplicate.
  • made sure this isn't a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • settings.txt
  • proxy support (Have you tried version 1.1.0+?)
  • 32 or 64 bit support (Have you tried version 1.1.3+?)
  • Character escaping (Have you tried version 1.1.6+?)
  • A standard shell environment (terminal/powershell)
  • A non-standard shell environment (Cmder, Hyper, Cygwin, git)

Expected Behavior

Using nvm root C:\Git\nvm should set my nvm root to that folder. Then running nvm install 10.17.0 and nvm use 10.17.0 should work.

Actual Behavior

nvm root will set my root directory to the right place. But nvm use 10.17.0 is not working and is giving me the error exec: "C:\\Git\\nvm\\elevate.cmd": file does not exist:

Steps to reproduce the problem:

I had a previously existing version of node running. Our security team changed our virus scanners to be more restrictive in our appdata folders so I tried to move NVM into an excluded folder using nvm root C:\Git. Then I installed the version of node that I needed nvm install 10.17.0 and when trying to do nvm use 10.17.0 this happened.

@Poltergeisen
Copy link
Author

Workaround:

Seems like re-installing nvm-windows into the root folder that I wanted fixed this issue. But this doesn't seem like the correct functionality.

@coreybutler
Copy link
Owner

When you say you had a version of Node installed, do you mean you had a prior version that was installed using nvm install or another standalone version installed? If I understand you correctly, you were expecting the versions previously installed with nvm4w to essentially be migrated to the new root directory. Is that accurate?

@Poltergeisen
Copy link
Author

Yes I had Nvm installed correctly in a different root and when using Nvm root command I had expected it to migrate to the new location.

@coreybutler
Copy link
Owner

@Poltergeisen thanks for clarifying.

NVM4W doesn't currently move prior installations, but I think that's a reasonable expectation in this circumstance. I've marked this as an enhancement request.

@capsocrates
Copy link

What is the point of the nvm root command?

I have followed the same steps as Poltergeisen (albeit with a different path and versions of node). And I am seeing the same error. But I had no expectation that any existing node versions would be moved. I had no existing node versions. I did these steps

nvm root W:\nvm-root
nvm install 12.13.1
nvm install 12.14
nvm install 12.16
nvm use 12.13.1

And like Poltergeisen I got

exec: "W:\\nvm-root\\elevate.cmd": file does not exist:

But if nvm root [path] has no effect unless you install nvm into the chosen [path] in the first place, what is the point of the command?

@coreybutler
Copy link
Owner

@capsocrates The command is used more often in CI/CD processes where there are no existing installations. Consider running in a Docker container. Once the container boots, you can point to a mounted directory (i.e. a pseudo-dynamic directory).

After reviewing the code again, I am thinking there may be a bug (as originally described), because the elevate command really should move to the new root. I may have mistakenly jumped to a conclusion about permissions instead focusing on the file transfer itself. That would be the bug if I can confirm it. NVM4W will still not move the prior node installations by default... but having an option to do that seems like a reasonable enhancement request. I don't want to enable that by default because there are a lot of users whose environments are spread across mapped/remote drives. Moving global node_modules can mean transferring many GB across networks, which is really tough for users who aren't on the fastest networks (lots of rural school districts, municpalities, etc). Stil, I'm thinking there should be a flag so devs have a choice in the matter.

@capsocrates
Copy link

That use case makes sense and would explain why the current behavior is considered to "work."

For my part I don't care about transferring the existing installs as part of this command (though I'm sure it would be a nice option to have in a flag). But it would be nice if it worked as described :)

@bl9l
Copy link

bl9l commented Apr 12, 2021

Hi guys.
The solution for those who face the same problem.

Copy these files
image

Into new root directory manually
image

@Symionow
Copy link

I agree, this is a bug. bl9l's solution works. I wanted my nvm4w install location and the root for my node installs to be different. I assumed that is the point of the root command. However, the files above also need to be where the root directory is set and the workaround is working but not expected.

@LesterReddy
Copy link

When installing nvm - set in installation to "c:\path}" ;
nvm root "c:\path"
mvm install version
nb c:\path => your choice

@userInner
Copy link

我也遇到了同样的问题。尝试使用了1.19版本,完美的解决了此问题
https://github.com/coreybutler/nvm-windows/releases

@mahede182
Copy link

mahede182 commented Apr 27, 2023

Try this.

  • Open the Command Prompt as an administrator. To do this, right-click on the Start menu and select "Command Prompt (Admin)".
  • Type the following command and press Enter: sfc /scannow

Repository owner deleted a comment from hughb77 Apr 27, 2023
@afsharm
Copy link

afsharm commented Jul 10, 2023

Hi guys. The solution for those who face the same problem.

Copy these files image

Into new root directory manually image

In my case I copied it from C:\Program Files\nvm as I originally installed nvm in this path.

@olallier
Copy link

olallier commented Sep 18, 2023

It is a bug of pointing to the correct folder in the code. The manual installation explicitly states those files are installed in %NVM_HOME% while the node.js versions are stored in %NVM_SYMLINK%.
when we run "nvm use (folder name of node.js)", we have the error " file does not exist:" because
it is looking for elevate.cmd in NVM_SYMLINK and NOT where it is supposed to look for, in NVM_HOME.
So it is a bug.

@seraph-b
Copy link

seraph-b commented Dec 6, 2023

Facing the same problem after installing through scoop. Changing the root path does not help.

@te1
Copy link

te1 commented Dec 11, 2023

Because this is the first thing that shows up on Google: I updated nvm to version 1.1.12 using scoop and now have this error whenever I nvm use <something>:
exec: "elevate.cmd": executable file not found in %PATH%:

I reverted back to nvm 1.1.11 and it works fine again.
scoop reset [email protected]

Mentioning #1069 for reference.

Looking at scoop nothing unexpected changed
ScoopInstaller/Main@a09fed8

Comparing the contents of 1.1.11/nvm-noinstall.zip and 1.1.12/nvm-noinstall.zip all the files seem to be present and only the nvm.exe has changed.

@nickolay
Copy link

nickolay commented Jan 3, 2024

The scoop issue about nvm-windows 1.1.12 not working is here: ScoopInstaller/Main#5311

@mar10br0
Copy link

The above solutions of copying the nvm application from the NVM_HOME into the NVM_ROOT folder is not working for me. My usecase may be slightly different (not moving a working installation to a different folder, but rather using nvm to manage node-version(s) without administrative rights:
nvm is offered as an approved software and installed through the company's software distribution.
As a user (without admin-rights), I then start with nvm root %APPDATA%\nvm (where I have write-permissions to install the managed node-versions)
Next nvm install 18.19.0 (my team's selected and tested node-version) works just fine (it installs a folder for node v18.19.0).
However, running nvm use 18.19.0 (very first time running the use command on my system) it fails with the missing elevate.cmd
Applying the trick to copy the nvm application from the installed location in Program Files (x86), no longer complains about missing elevate, but now the windows admin-permission popup shows (presumably to create/redirect the symlink?). And that's where I'm truly stuck, as I don't have (nor be allowed to have) local admin permissions.

As @olallier mentioned, I believe the bug to be confusing NVM_HOME and NVM_ROOT. (hoping that the installed location of elevate.cmd can elevate the permissions of nvm to manage the sym-link.

PS: the software distribution in our organisation is not giving any control over the installation of nvm itself.

@coreybutler
Copy link
Owner

@mar10br0 I hate to say it, but I don't think there is anything you can do other than petition the powers that be to grant you more capabilities. nvm use establishes a symlink to the version you want to use. Windows does not grant symlink privileges to users by default. You either have to be an admin (which is the only way on old versions of Windows) or you must be explicitly granted permission to manage symlinks. Microsoft recognized this as a pain point several years ago and introduced "Developer Mode". By enabling this, you'll have the ability to manage symlinks without requiring full admin privileges. Your org will probably have to enable this for you though, given the locked down nature of the environment you're working in.

See https://github.com/coreybutler/nvm-windows/wiki/Common-Issues#permissions-exit-1-exit-5-access-denied-exit-145.

Also, see Runtime, which is the version manager we're building for enterprise/corporate use.

@mar10br0
Copy link

Thanks @coreybutler, I'll dive into those resources 👍

@IvanBanifatsyeu
Copy link

Try this.

  • Open the Command Prompt as an administrator. To do this, right-click on the Start menu and select "Command Prompt (Admin)".
  • Type the following command and press Enter: sfc /scannow

It helped me‼!!!!!!!!!!!!!!!

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

No branches or pull requests