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

The process cannot access the file because it is being used by another process #580

Closed
qq1209974887 opened this issue Nov 7, 2020 · 19 comments

Comments

@qq1209974887
Copy link

Environment: Windows10 operating system

Quesion: npm download failed, Rolling Back, Rollback failed. Remove npm-v3.10.10.zip: The process cannot access the file because it is being used by another process.

image

Tried solutions: Computer shutdown and restart, still not solve the problem, is still the same error.

@coreybutler
Copy link
Owner

Cannot recreate:

image

Things to look for

  1. Make sure you've uninstalled any prior versions of Node that were installed without NVM4W. Same goes for npm.
  2. Make sure a firewall isn't blocking the download.
  3. Make sure your user has the appropriate permissions (this is unlikely to be the problem in this particular case, since you can get a partial file)

This is most commonly caused by a network failure. You can also download npm and install it manually if needed.

@mhscott64
Copy link

We see this frequently in our shop. The message is generated in web.go->func Download(...). The top of this function contains:

 output, err := os.Create(target)
 if err != nil {
   fmt.Println("Error while creating", target, "-", err)
 }
 **defer output.Close()**
...
**  defer response.Body.Close()**

Later, there are 2 different error handling stanzas. The one for ctrl-c includes:

	output.Close()
	response.Body.Close()

The one for an HTTP failure does not include these closes. So, in the event of an HTTP failure, the code attempts to delete the folder containing the failed download, but cannot because the output file is still open. This results in the "rollback failed" message.

If this analysis is correct, one solution would be to add the closes that are found in the ctrl-c handler to the http error handler.

@coreybutler
Copy link
Owner

Resolved in 5751e53. This will be released in v1.1.9.

@lfl976
Copy link

lfl976 commented Feb 23, 2022

I modify the nvm mirror(npm&node) and met the same issues,delete the mirror solved the problem.

@gregovin
Copy link

gregovin commented May 7, 2022

The issue is still present on v1.1.9, I just tried to use nvm install 13.7.0 and cannot use that version

@drewg2009
Copy link

drewg2009 commented May 10, 2022

Same I am also getting this issue:

C:\WINDOWS\system32>nvm install 16.13.0Downloading node.js version 16.13.0 (64-bit)... CompleteCreating C:\Users\n0311764\AppData\Roaming\nvm\temp Downloading npm version 8.1.0... Download failed. Rolling Back.Rollback failed. remove C:\Users\n0311764\AppData\Roaming\nvm\temp\npm-v8.1.0.zip: The process cannot access the file because it is being used by another process.Could not download npm for node v16.13.0.Please visit https://github.com/npm/npm/releases/tag/v8.1.0 to download npm.It should be extracted to C:\Users\n0311764\AppData\Roaming\nvm\v16.13.0

@tomgcavanaugh
Copy link

Turn on "Developer Mode" by searching for the developer settings.

@drewg2009
Copy link

Turn on "Developer Mode" by searching for the developer settings.

Developer settings for NVM?

@coreybutler
Copy link
Owner

Developer Mode is part of Windows. See https://github.com/coreybutler/nvm-windows/wiki/Common-Issues#permissions-exit-1-exit-5-access-denied-exit-145

image

@tomgcavanaugh
Copy link

tomgcavanaugh commented May 11, 2022

On other versions of Windows:

image

@pedroyan
Copy link

on NVM 1.1.9, I'm still getting this problem, despite enabling Developer Mode and running from a privileged command prompt

image

Downgrading NVM to 1.1.7 solved the issue

@nicolasguzca
Copy link

Developer Mode is part of Windows. See https://github.com/coreybutler/nvm-windows/wiki/Common-Issues#permissions-exit-1-exit-5-access-denied-exit-145

image

This worked perfectly, thanks

@Srutututu
Copy link

I get this error only if trying to install node 14.19.2
I can install 10.23.0 and 12.23.0 without issues and use them.
Maybe this can help identify the cause?

@johnvt
Copy link

johnvt commented May 17, 2022

I get this error only if trying to install node 14.19.2 I can install 10.23.0 and 12.23.0 without issues and use them. Maybe this can help identify the cause?

Confirmed. I could even install 14.9.1 (npm 6.14.16) without problems, while 14.9.2 (npm 6.14.17) gives "download failed".

@Juuldamen
Copy link

I see the same behaviour as @johnvt. Older versions such as 14.17.5 and 14.9.1 work just fine. But 14.19.2 doesn't. Toggling the developer mode setting on or off doesn't seem to matter.

The command is ran in an elevated Git Bash Windows Terminal instance.

$ nvm install 14.19.2
Downloading node.js version 14.19.2 (64-bit)...
Complete
Downloading npm version 6.14.17... Download failed. Rolling Back.
Rollback failed. remove C:\Users\xxxxx\AppData\Roaming\nvm\temp\npm-v6.14.17.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v14.19.2.
Please visit https://github.com/npm/cli/releases/tag/v6.14.17 to download npm.
It should be extracted to C:\Users\xxxxx\AppData\Roaming\nvm\v14.19.2
$ nvm version
1.1.9

Output of winver
image

@joshtransient
Copy link

Can also confirm this happens for 14.19.3 for me.

@xiaoyang678
Copy link

nodejs 14.19.3,14.19.2 is failed.

@xiaoyang678
Copy link

#373 (comment)

npm/cli#4890

The above helped me, but the specific reason is still unknown, maybe npm official problem

@maddyjolly2112
Copy link

maddyjolly2112 commented Jul 26, 2023

I had the same problem, it only installs which nvm list available shows in the list, rest fails.

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

No branches or pull requests