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

If .yarnrc is hidden on Windows, yarn add [package] fails #4306

Closed
ghost opened this issue Sep 4, 2017 · 15 comments
Closed

If .yarnrc is hidden on Windows, yarn add [package] fails #4306

ghost opened this issue Sep 4, 2017 · 15 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2017

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

bug

What is the current behavior?
The command yarn add vue fails with the error message

Error: EPERM: operation not permitted, open 'C:\Users\username-obfuscated\.yarnrc'
at Error (native)

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

  1. Mark .yarnrc as a hidden file on Windows.
  2. Call command yarn add vue
  3. Package installs successfully, but at the end of the yarn installation output, the error is received.

What is the expected behavior?
Yarn should recognize that .yarnrc exists, even if it a hidden file.

Please mention your node.js, yarn and operating system version.
Node.js version 6.11.2, yarn version 0.27.5, operating system Windows 10 Home, version 1703, build 15063.483

@arcanis
Copy link
Member

arcanis commented Sep 4, 2017

If we can't read this file, not sure we can't do much

@ghost ghost closed this as completed Sep 6, 2017
@Muukuro
Copy link

Muukuro commented Dec 18, 2017

I had this issue too. Manually unhiding and rehiding ~.yarnrc in Explorer fixed it for me.
Not sure, but it would almost seem like Yarn creates this file in a non-standard 'hidden' way, making it invisible or unavailable for applications.

@royalaid
Copy link

royalaid commented Dec 7, 2018

Just want to say that I had to touch ~/.yarnrc then hide and unhide the file like the comment above this.

@joalcava
Copy link

Why is this closed? The issue still exists. If you hide .yarnrc every add will end with error: EPERM. This also causes creat-react-app and other bootstrappers to fail.

@arcanis
Copy link
Member

arcanis commented Jan 10, 2019

Why is this closed? The issue still exists

Because it's not a problem Yarn can fix as far as I know. If I'm incorrect, then a PR (that would explain in detail the problem and the resolution) will go a long way into fixing this 🙂

@joalcava
Copy link

@arcanis Thanks for your response, I don't know much about the yarn's internals but I was supposing this was concerning to yarn since most applications does not have problems with hidding its dot files in windows.

@robross0606
Copy link

robross0606 commented Sep 5, 2019

I don't understand why node.js developers have a mental block on this type of a problem. A hidden file is NOT a read-only file. Nor is it a non-existent file. Technically, all Unix files that start with "." are hidden. On Windows it is a separate flag, but the behavior should be the same. The file is available. Visibility settings are not the same as permissions. This is a BUG and should not have been closed.

Here is a similar issue that node itself had: nodejs/node#5261

Only they owned the issue, called it a bug, and fixed it.

@dstaley
Copy link

dstaley commented Nov 28, 2019

I'm willing to take a stab at this! Leaving this note here so that I can come back to it in a few days.

On Windows, opening a file in w mode will throw EPERM if the file has the hidden attribute. Instead, we should open the file in r+. However, in order to do this, we need to ensure that the file exists. So, I think the easiest implementation would be to update this function to create the file if it doesn't exist, then open it in r+ mode, and the write the data to the file. Since it's using a promisified version of fs.writeFile, we could in theory update writeFile to have this behavior. That'll be what I'll investigate.

@alidavodii
Copy link

hi my friends , go to c:/users/{pc name}/
show hidden file
properties .yarnrc
hidden uncheck
good luck
Annotation 2019-12-11 102530

@stephtr
Copy link

stephtr commented May 23, 2020

Sorry for being slightly off-topic, but why does the yarnrc file on Windows gets saved to the user's folder instead of %APP_DATA%? If the latter would be the case, there would be in my opinion no need to manually hide the file.

@karlhorky
Copy link

Seems like you can also fix this on the command line:

attrib -h C:\Users\<your username>\.yarnrc

Or, of you're using Git Bash:

attrib -h /c/Users/<your username>/.yarnrc

@Lschulzes
Copy link

hi my friends , go to c:/users/{pc name}/
show hidden file
properties .yarnrc
hidden uncheck
good luck
Annotation 2019-12-11 102530

That worked for me, thanks bro!

@zevsap
Copy link

zevsap commented Sep 13, 2021 via email

@sryze
Copy link

sryze commented Sep 20, 2021

Has this been fixed?

@lul-g
Copy link

lul-g commented Jul 26, 2022

Nope

This issue was closed.
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