yarn icon indicating copy to clipboard operation
yarn copied to clipboard

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

Open oscar-b opened this issue 10 years ago • 44 comments

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)

oscar-b avatar Oct 13 '16 12:10 oscar-b

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)

Daniel15 avatar Oct 13 '16 17:10 Daniel15

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 avatar Oct 17 '16 10:10 oscar-b

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

oscar-b avatar Oct 18 '16 04:10 oscar-b

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

Daniel15 avatar Oct 18 '16 06:10 Daniel15

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.

danielkcz avatar Nov 01 '16 08:11 danielkcz

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.

wclr avatar Nov 09 '16 07:11 wclr

@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.

danielkcz avatar Nov 15 '16 14:11 danielkcz

@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?

Tapppi avatar Nov 15 '16 15:11 Tapppi

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! ;)

atrauzzi avatar Nov 21 '16 00:11 atrauzzi

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.

danielkcz avatar Nov 21 '16 13:11 danielkcz

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?

vijay-stayntouch avatar Nov 22 '16 05:11 vijay-stayntouch

@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.

danielkcz avatar Nov 22 '16 07:11 danielkcz

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!

jwngr avatar Nov 23 '16 00:11 jwngr

Is this the same issue as #872?

Daniel15 avatar Nov 23 '16 20:11 Daniel15

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.

danielkcz avatar Nov 30 '16 10:11 danielkcz

@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.

vijay-stayntouch avatar Dec 01 '16 05:12 vijay-stayntouch

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

danielkcz avatar Dec 01 '16 06:12 danielkcz

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 [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" 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

hemedani avatar Feb 21 '17 20:02 hemedani

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

domjtalbot avatar Apr 13 '17 09:04 domjtalbot

I find this issue from time to time installing packages with npm or yarn, my workaround is going to file manager, right click on /node_modules main folder, selecting properties, and check-uncheck "read-only". You can do it also using attrib in command line. Then you retry installation and it works.

Franciscoco avatar Jul 31 '17 07:07 Franciscoco