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

EPERM: operation not permitted #79

Closed
brodybits opened this issue Dec 17, 2017 · 14 comments
Closed

EPERM: operation not permitted #79

brodybits opened this issue Dec 17, 2017 · 14 comments

Comments

@brodybits
Copy link
Contributor

Given a local installation I encountered the following error when attempting to add a Node version:

C:\Users\brodybits\chris-work
λ nvs add carbon
Downloading [###########################################################################################] 100%
Extracting  [###########################################################################################] 100%
EPERM: operation not permitted, rename 'C:\Users\brodybits\AppData\Local\nvs\node\8.9.3\x64\node-v8.9.3-win-x64\node_modules' -> 'C:\Users\brodybits\AppData\Local\nvs\node\8.9.3\x64\node_modules'
Try running again as Administrator.

I don't think I should have to run as administrator if I have everything installed in my local area. Or am I mistaken somehow?

@brodybits
Copy link
Contributor Author

What is strange is that I can do nvs use and nvs link by major version number but not by code names such as lts, carbon, boron, etc. I am very suspicious that there is something wrong with the way nvs uses code names on my new system. I will just continue to go by major version number for now. I am still hopeful that we can find the root cause and proper solution at some point.

@jasongin
Copy link
Owner

You're right, you shouldn't need to run as administrator for installation in your user directory. In this case I think that error message is misleading.

The rename must have failed for some other reason. I've seen a couple reports of this in the past, but haven't been able to reproduce it myself. Maybe a virus scanner or something is locking the directory? I don't know. Does it happen again if you retry?

@jasongin
Copy link
Owner

What errors are you seeing from nvs use and nvs link? Those don't do a rename.

@brodybits
Copy link
Contributor Author

Here is some more output:

C:\Users\brodybits\chris-work
λ nvs add lts
Already added at: %LOCALAPPDATA%\nvs\node\8.9.3\x64\node.exe
To use this version now: nvs use node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs ls
  node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs ls
  node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs use lts
Specified version not found.
To add this version now: nvs add node/lts

C:\Users\brodybits\chris-work
λ node --version
'node' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\brodybits\chris-work
λ nvs --version
1.4.3

C:\Users\brodybits\chris-work
λ nvs ls
  node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs use carbon
Specified version not found.
To add this version now: nvs add node/carbon

C:\Users\brodybits\chris-work
λ nvs use 8
PATH += %LOCALAPPDATA%\nvs\node\8.9.3\x64

C:\Users\brodybits\chris-work
λ nvs ls
 >node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs link 8
%LOCALAPPDATA%\nvs\default -> %LOCALAPPDATA%\nvs\node\8.9.3\x64
User profile PATH += %LOCALAPPDATA%\nvs\default

C:\Users\brodybits\chris-work
λ nvs add boron
Downloading [###########################################################################################] 100%
Extracting  [###########################################################################################] 100%
EPERM: operation not permitted, rename 'C:\Users\brodybits\AppData\Local\nvs\node\6.12.2\x64\node-v6.12.2-win-x64\node_modules' -> 'C:\Users\brodybits\AppData\Local\nvs\node\6.12.2\x64\node_modules'
Try running again as Administrator.

C:\Users\brodybits\chris-work
λ nvs ls
>#node/8.9.3/x64
  node/6.12.2/x64

C:\Users\brodybits\chris-work
λ nvs use boron
Specified version not found.
To add this version now: nvs add node/boron

C:\Users\brodybits\chris-work
λ nvs use 6
PATH -= %LOCALAPPDATA%\nvs\node\8.9.3\x64
PATH += %LOCALAPPDATA%\nvs\node\6.12.2\x64

C:\Users\brodybits\chris-work
λ node --version
v6.12.2

I just got an updated Lenovo laptop from a computer repair shop and they added some kind of an antivirus program. I would not be surprised if this would be the explanation. I will leave this in case someone finds a better explanation in the future, will just manage by major version number for now.

@brodybits
Copy link
Contributor Author

@jasongin
Copy link
Owner

It looks like because of that EPERM failure the installations didn't complete. Normally one of the last things that happens is persisting the LTS tag. That's why later trying to nvs use or nvs link using the carbon, boron, or lts aliases didn't work. Try to nvs rm and nvs add those versions again. If they can install completely then you should be fine. If you keep getting the EPERM error then I'd want to do some troubleshooting to see if we can understand what cases that.

@brodybits
Copy link
Contributor Author

After removing and adding back a couple times it seems to be OK now. I am wondering if there is some intermediate path that was not created the right way the first time around?

Here is the additional output:

C:\Users\brodybits\chris-work
λ node --version
v6.12.2

C:\Users\brodybits\chris-work
λ nvs rm boron
Specify a semantic version.

C:\Users\brodybits\chris-work
λ nvs rm carbon
Specify a semantic version.

C:\Users\brodybits\chris-work
λ nvs rm lts
Specify a semantic version.

C:\Users\brodybits\chris-work
λ nvs rm 6 8
PATH -= %LOCALAPPDATA%\nvs\node\6.12.2\x64
PATH += %LOCALAPPDATA%\nvs\default
- C:\Users\brodybits\AppData\Local\nvs\node\6.12.2\x64

C:\Users\brodybits\chris-work
λ nvs ls
>#node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs rm 8
User profile PATH -= %LOCALAPPDATA%\nvs\default
- %LOCALAPPDATA%\nvs\default
PATH -= %LOCALAPPDATA%\nvs\default
- C:\Users\brodybits\AppData\Local\nvs\node\8.9.3\x64

C:\Users\brodybits\chris-work
λ nvs ls

C:\Users\brodybits\chris-work
λ nvs add lts
Extracting  [###########################################################################################] 100%
EPERM: operation not permitted, rename 'C:\Users\brodybits\AppData\Local\nvs\node\8.9.3\x64\node-v8.9.3-win-x64\node_modules' -> 'C:\Users\brodybits\AppData\Local\nvs\node\8.9.3\x64\node_modules'
Try running again as Administrator.

C:\Users\brodybits\chris-work
λ nvs add boron
Extracting  [###########################################################################################] 100%
Added at: %LOCALAPPDATA%\nvs\node\6.12.2\x64\node.exe
To use this version now: nvs use node/6.12.2/x64

C:\Users\brodybits\chris-work
λ nvs use boron
PATH += %LOCALAPPDATA%\nvs\node\6.12.2\x64

C:\Users\brodybits\chris-work
λ node --version
v6.12.2

C:\Users\brodybits\chris-work
λ nvs ls
  node/8.9.3/x64
 >node/6.12.2/x64 (Boron)

C:\Users\brodybits\chris-work
λ nvs rm carbon
Specify a semantic version.

C:\Users\brodybits\chris-work
λ nvs rm 8
- C:\Users\brodybits\AppData\Local\nvs\node\8.9.3\x64

C:\Users\brodybits\chris-work
λ nvs add lts
Extracting  [###########################################################################################] 100%
Added at: %LOCALAPPDATA%\nvs\node\8.9.3\x64\node.exe
To use this version now: nvs use node/8.9.3/x64

C:\Users\brodybits\chris-work
λ nvs ls
  node/8.9.3/x64 (Carbon)
 >node/6.12.2/x64 (Boron)

C:\Users\brodybits\chris-work
λ nvs use lts
PATH -= %LOCALAPPDATA%\nvs\node\6.12.2\x64
PATH += %LOCALAPPDATA%\nvs\node\8.9.3\x64

C:\Users\brodybits\chris-work
λ node --version
v8.9.3

@jasongin
Copy link
Owner

Closing since I haven't heard any further reports of this problem. Feel free to reactivate if it's still valid.

@stevehipwell
Copy link

@jasongin I regularly get this issue when running nvs upgrade. Sometimes I can fix it by resetting the inherited permissions of the node folder.

r15ch13 pushed a commit to ScoopInstaller/Scoop that referenced this issue Dec 13, 2018
Add nvs v1.5.1, a more powerful Node.js versions tool on Windows than nvm-windows made by @jasongin.

- Name: Node Version Switcher
- Description: A cross-platform tool for switching between versions and forks of Node.js
- Version: 1.5.1
- Homepage: https://github.com/jasongin/nvs
- Basic usage
  - To add the latest version of node:
    ```powershell
    $ nvs add latest
    ```
  - Or to add the latest LTS version of node:
    ```powershell
    $ nvs add lts
    ```
  - Then run the `nvs use` command to add a version of node to your PATH for the current shell:
    ```powershell
    $ nvs use lts
    PATH += ~/.nvs/node/10.14.2/x64
    ```
  - To add it to PATH permanently, use `nvs link`:
    ```powershell
    $ nvs link lts
    ```
- Known Issue: Sometimes nvs will show an `EPERM: operation not permitted.` error during first adding some Node.js version, and it is due to JavaScript `fs.renameSync` function. The author hasn't been able to reproduce it himself (jasongin/nvs#79 (comment)), and in my practice, `nvs rm` and `nvs add` again should solve the problem. This only occurs in first `nvs add` run after re/install nvs.
@jasongin
Copy link
Owner

Reopening because some people are still hitting this. I'll try to investigate more.

@jasongin jasongin reopened this Dec 13, 2018
@niheaven
Copy link

I got an EPERM error when I install nvs by msi, and also got it by git clone into some non-system volumn (E:..., not $Env:LOCALAPPDATA). In such situations, simply rm and add didn't solve the error. By setting $Env:NVS_HOME to some subdir that is not root dir of nvs, the error occurs as before.

But when I try to make a scoop manifest and persist the NVS_HOME, the error gone occasionally. Sometimes it happens once after first nvs add, and rm/add is okay. And sometimes it is always okay. I try to delete persisted nvs_home for a pure installation and not delete for a reinstallation, but things happened irregularly.

This is due to some dir permission inheritance during fs.renameSync(), that is what I can sure, and I hope it should help.

@vladimiry
Copy link

vladimiry commented Dec 22, 2018

Just got this error running Tarvis CI job (windows os):

EPERM: operation not permitted, rename 'C:\ProgramData\nvs\node\10.14.2\x64\node-v10.14.2-win-x64\node_modules' -> 'C:\ProgramData\nvs\node\10.14.2\x64\node_modules'

See here why EPERM error is happening on Windows isaacs/node-graceful-fs#119. So often it happens because the resource is locked, but not because of a lack of access rights.

I use this module to cope with EPERM errors on Windows https://github.com/vladimiry/fs-no-eperm-anymore.

@jasongin
Copy link
Owner

Thanks for the links, those are helpful! I will put some form of EPERM workaround into nvs.

@jasongin
Copy link
Owner

Fixed in nvs 1.5.2

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

5 participants