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

Windows fails with EPERM: operation not permitted, all files are read-only #992

Closed
oscar-b opened this issue Oct 13, 2016 · 44 comments · Fixed by #4301
Closed

Windows fails with EPERM: operation not permitted, all files are read-only #992

oscar-b opened this issue Oct 13, 2016 · 44 comments · Fixed by #4301

Comments

@oscar-b
Copy link

oscar-b commented Oct 13, 2016

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When performing any operation with yarn (add for instance) it errors with:

EPERM: operation not permitted, open 'C:\foo\node_modules\firebase\app-node.js'
at Error (native)

If the current behavior is a bug, please provide the steps to reproduce.

  1. Use Windows :(
  2. Use yarn
  3. Failure

To fix the issue, right click the node_modules folder and un-check "Read-only". Wait. Re-run yarn command. Now it works, like magic! After yarn is done, all files are back to being read-only though.

What is the expected behavior?
Shouldn't have to mark the files as readable.

Please mention your node.js, yarn and operating system version.
node v6.3.1
yarn v0.15.1
Windows 10 (anniversary edition)

@Daniel15
Copy link
Member

To fix the issue, right click the node_modules folder and un-check "Read-only".

Is Yarn marking node_modules as readonly, or is something else doing that? I can't repro on Windows with a brand new app (ie. yarn init && yarn add react)

@oscar-b
Copy link
Author

oscar-b commented Oct 17, 2016

Hi @Daniel15

Could you please try this in a clean directory?

yarn init
yarn add firebase
yarn add react

The last command gives me:

C:\Dev\yarntest>yarn add react
yarn add v0.15.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
error EPERM: operation not permitted, open 'C:\Dev\yarntest\node_modules\firebase\app-node.js'
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

I'm not sure if it's something the firebase packages does?

@oscar-b
Copy link
Author

oscar-b commented Oct 18, 2016

For clarification; I tried the same steps but with react and eslint and didn't see the same error.

@Daniel15
Copy link
Member

Thanks for the information! I can replicate the issue on Windows but not on Debian Linux.

@danielkcz
Copy link

danielkcz commented Nov 1, 2016

I would say this is more of a critical error as it prevents even basic use of Yarn in any project using firebase module.

Removing read-only flag recursively works, but only temporarily. Even running just yarn reruns whole linking dependencies phase and returns these read-only flags back.

Creating fresh project with yarn init and installing any single dependency sets read-only flag to all directories (not files) starting from node_modules. However in case of firebase module, the files are also read-only for some reason. Doing same thing with NPM does not set read-only to files.

@wclr
Copy link
Contributor

wclr commented Nov 9, 2016

Yes this is quite annoying.

@Daniel15
Another problem I have I install the package and on postinstall step it sets chmod some-file 400, and while some operations yarn fail with a like error on this file, (if I set permissions to 644 it runs ok). So I hope you fix original issue and my issue will gone too.

@danielkcz
Copy link

@Tapppi (quote from issue)

P.S. Regarding #992, you could probably write a oneliner "postinstall" script to fix the permissions after every install.

That would kinda erase usefulness of Yarn, don't you think? Removing those read-only flags makes Yarn do whole linking process again. Only performance save would about using cache instead of downloading over the network every time.

@Tapppi
Copy link

Tapppi commented Nov 15, 2016

@FredyC I fail to see how a postinstall script erases yarns usefulness? It's still most likely multiple times faster than npm when installing, and has a lock file. If that makes yarn unpreferable for you, I would think yarn is not preferable anyways in its current form?

@atrauzzi
Copy link

Encountering this as well. Nothing special about my project, I'm just getting around it by blowing out my node_modules folder for new packages for now.

Hopefully this resolves soon, thank goodness yarn is so damned fast! ;)

@danielkcz
Copy link

danielkcz commented Nov 21, 2016

Well this is interesting. If you download actual tarball of the firebase module, those read-only attributes are already there! ... https://registry.npmjs.org/firebase/-/firebase-3.4.1.tgz

That means it's not exactly Yarn fault. I assume that what NPM does differently is to actually remove that flag upon installation. Essentially that might be solution that Yarn should do as well because you never know what other module can be affected like that.

I've actually tried to publish my own package to NPM with read-only flag set on the one file. Sadly that's not the source of the problem. Files are published without the flag.

So I've filed support request with Firebase to see if there is something they can change in their publishing process.

@vijay-stayntouch
Copy link

Can we hope that in future Yarn release this case will be dealt with, using NPM approach or otherwise.

Just a FYI, it will also work if you remove firebase first, then add your required packages and at last add firebase back. So is Yarn updating the permissions when firebase is removed?

@danielkcz
Copy link

danielkcz commented Nov 22, 2016

@vijay-stayntouch No, Yarn does nothing about it. Main problem is that if you have firebase there with read only flags and the "linking dependencies" process has to be executed for some reason, it is unable to touch these files and fails. Although I am bit unsure how it's possible that Yarn can actually delete those files with read-only flags.

@jwngr
Copy link

jwngr commented Nov 23, 2016

Hey, Firebase engineer here. We are going to fix this on our end by making sure our next release no longer contains read-only files. That being said, this does seem like unexpected behavior and probably should get fixed across the board for Yarn, as it is in npm. Thanks!

@Daniel15
Copy link
Member

Is this the same issue as #872?

@danielkcz
Copy link

danielkcz commented Nov 30, 2016

Good news to everyone who has trouble with this. There is a new firebase module 3.6.2 without read only flags and it works flawlessly now.

I recommend closing this one in favor of #961 which is more generic and related to Yarn only.

@vijay-stayntouch
Copy link

@FredyC Great news!

The question still hangs up in the air that if any other packages makes their code read-only. The same issue will happen again.

@danielkcz
Copy link

@vijay-stayntouch Yea, that's what #961 should try to solve really.

@hemedani
Copy link

hemedani commented Feb 21, 2017

I have the same issue with yarn add react-hot-loader --dev it says :

yarn add v0.20.3
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.1.1: The platform "linux" is incompatible with this module.
info "fsevents@1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
error An unexpected error occurred: "EPERM: operation not permitted, utime '/home/syd/Work/taxibs/zaher/node_modules/source-map/README.md'".
info If you think this is a bug, please open a bug report with the information provided in "/home/syd/Work/taxibs/zaher/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

I'm do a yarn cache clean and exec the yarn add ... again but the problem still there.
I'm on the ubuntu 16.04
node v6.9.4 & npm v3.10.10

@domjtalbot
Copy link

I was getting the same issue - the only solution that worked for me was to use rimraf node_modules to delete the node_modules folder then reinstall all packages using yarn

arcanis pushed a commit that referenced this issue Sep 4, 2017
* Fix: make sure all extracted tarballs are r/w enabled

**Summary**

Fixes: #992. This issue was supposed to be fixed by #2826 but it
was not setting directory permissions wide enough. This patch uses
the `readable` and `writable` options provided by the `tar-fs`
package which essentially sets everything to `0o777`.

**Test plan**

N/A

* fewer perms
@BYK BYK moved this from Active to Done in Yarn 1.0 Sep 5, 2017
joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
* Fix: make sure all extracted tarballs are r/w enabled

**Summary**

Fixes: yarnpkg#992. This issue was supposed to be fixed by yarnpkg#2826 but it
was not setting directory permissions wide enough. This patch uses
the `readable` and `writable` options provided by the `tar-fs`
package which essentially sets everything to `0o777`.

**Test plan**

N/A

* fewer perms
@strider72
Copy link

On Windows, be sure to run the Command Prompt "As Administrator". ::facepalm::

@James-E-Adams
Copy link

Tried everything listed here - the only way I was able to fix it was:

npm install -g rimraf
rimraf node_modules

as suggested by @domjtalbot.

@moeinrahimi
Copy link

moeinrahimi commented Apr 9, 2018

also this happens when you have two instance of yarn running trying to install packages in different projects

@timlorepublic
Copy link

happens to me too, npm 5.8.0, and the only one working is pointed by @domjtalbot and @James-E-Adams

@gutbk201
Copy link

gutbk201 commented May 1, 2018

I run into the same issue when I have a server running with nodemon, then adding a package yarn add bcrypt. With @rmorrise 's comment I fix my problem.Never know the server running will affect installing.

@jayarjo
Copy link

jayarjo commented Aug 14, 2018

@rmorrise +1, would be logical if yarn could detect such circumstance and throw a meaningful warning instead.

@Kagigz
Copy link

Kagigz commented Mar 26, 2019

For info: I had the same issue after cancelling the installation of a package (ctrl+c), and trying to install another package afterwards. I also had a server running but it didn't cause errors when I added other packages before.

@gorgos
Copy link

gorgos commented Apr 18, 2019

download (1)

I've run into this error quite a few times now and only a reboot of Windows helped.

@andsmi97
Copy link

andsmi97 commented Apr 22, 2019

I've had the same problem. The reason caused this bug was running create-react-app development server in ubuntu for windows bash. Stopping the server solved the problem.

@coder006
Copy link

coder006 commented May 3, 2019

download (1)

I've run into this error quite a few times now and only a reboot of Windows helped.

Usually i prefer downvoting such answers, but this was literally the only thing that worked for me 🤦‍♂

@MakhouT
Copy link

MakhouT commented May 28, 2019

download (1)

I've run into this error quite a few times now and only a reboot of Windows helped.

This indeed did the trick for me...

@ScottGuymer
Copy link

At least for me, this seems to be caused by having vscode open.

@eyadfarra
Copy link

Make sure your app(angular, react, etc...) is turned off before npm install

@Gameghostify
Copy link

@ScottGuymer

I can't believe this works

thank you for your solution

@ScottGuymer
Copy link

@Gameghostify me either 😄

You're welcome.

@josefanostylus
Copy link

Check if you have a node process running, shut if off and try again

@apolopena
Copy link

I was running yarn from a vscode terminal so I restarted vscode and that did the trick

@gayathri-kannanv
Copy link

yep, it sometimes sucks while doing in Win (like developing Ionic2/3 in Win, permanently throwing EPERM errors for i.e installing/mod npm packs and other stuff); it may be cuzed by antivirus software; unchecking read only attr from all node_modules;
Also, try to add .npmrc file to your forlder (c:/users/) with content unsafe-perm=true; add the same file to your project's root; last resort: run powershell as admin and elevate with Start-Process powershell -Verb runAs - gonna open new elevated powershell window, which should be able to operate

IT REALLY WORKED. THANK YOU.

@jerry-santana
Copy link

@Gayathri-K-2000 Can you provide more details please? I'm facing same issue but didn't work. Please provide example of what you did if possible. Thank you!

@gayathri-kannanv
Copy link

@Gayathri-K-2000 Can you provide more details please? I'm facing same issue but didn't work. Please provide example of what you did if possible. Thank you!

I unchecked 'read only' from properties of node modules and ran in cmd as administrator. It works.

@tommylenz
Copy link

Check if you have a node process running, shut if off and try again

That indeed was my problem here as well. Same goes for react apps, e.g. when you are prompted to install node-sass - you can't do it while your app is running. Thanks all!

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.