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

Yarn global packages installed in incorrect directory on Windows #3055

Closed
dheerajbhaskar opened this issue Apr 6, 2017 · 14 comments
Closed

Comments

@dheerajbhaskar
Copy link

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

bug (regression?)

What is the current behavior?
yarn add global fails with EPERM: operation not permitted

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

  1. install yarn using MSI on windows 10 x64
  2. do yarn init and then yarn global add codeceptjs

What is the expected behavior?
same as npm -g install codeceptjs i.e. install the package globally without errors

Please mention your node.js, yarn and operating system version.
nodejs v7.8
yarn v0.22.0
windows 10 pro x64

Stacktrace:

yarn init v0.22.0
question name (shaadi-try):
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
success Saved package.json
Done in 4.13s.

C:\my-home\AutomationProjects\CodeceptProjects\shaadi-try>yarn global add codeceptjs
yarn global v0.22.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "codeceptjs@0.5.1" with binaries:
      - codeceptjs
error An unexpected error occurred: "EPERM: operation not permitted, open 'C:\\Program Files\\nodejs\\codeceptjs.cmd'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\Dheeraj\\AppData\\Local\\Yarn\\config\\global\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

yarn error log:
https://gist.github.com/dheerajbhaskar/07cdc55e1d80282c4782f948638fa7c4

@dheerajbhaskar
Copy link
Author

Wasn't this fixed sometime back?

C:\my-home\AutomationProjects\CodeceptProjects\shaadi-try>yarn global bin
C:\Program Files\nodejs

@ghost
Copy link

ghost commented Apr 6, 2017

You have to run this command as amministrator on windows systems

@Daniel15
Copy link
Member

Daniel15 commented Apr 7, 2017

There's a known bug at the moment where we're trying to install global packages into the Node.js directory rather than Yarn's AppData directory.

@dheerajbhaskar
Copy link
Author

dheerajbhaskar commented Apr 7, 2017 via email

@Daniel15 Daniel15 changed the title yarn global add errors on windows Yarn global packages installed in incorrect directory on Windows Apr 7, 2017
@ghost
Copy link

ghost commented Apr 7, 2017

Npm I -g doesn't require admin privileges, why should yarn.

That's because yarn is trying to install the link to the package inside /Program Files/ and in windows you need admin privileges to write in this folder:

"EPERM: operation not permitted, open 'C:\Program Files\nodejs\codeceptjs.cmd'"

@dheerajbhaskar
Copy link
Author

dheerajbhaskar commented Apr 8, 2017 via email

@Daniel15
Copy link
Member

Daniel15 commented Apr 8, 2017

Yes, that's the bug. It's not supposed to put the packages in Program Files. It's supposed to put them in LocalAppData.

@F3n67u
Copy link

F3n67u commented Apr 9, 2017

I was getting the same issue on Windows 10

@wizicer
Copy link

wizicer commented Apr 10, 2017

I'm hitting this issue today when I try to migrate from npm.

Seems there are more aging issues talking about the same.

#992
#1407
#2192

@Daniel15
Copy link
Member

If anyone wants to investigate this, pull requests are always appreciated! It just sounds like whatever code determines the directory for global packages is incorrectly returning the Program Files directory.

@Sudeethar
Copy link

Luke123443 is correct, That's because yarn is trying to install the link to the package inside /Program Files/ and in windows you need admin privileges to write in this folder:

"EPERM: operation not permitted, open 'C:\Program Files\nodejs

@ghost
Copy link

ghost commented Apr 21, 2017

I tried the last couple of hours to migrate from npm, but I give up: every successful workaround leads to a new permission error on another file.

I'm not complaining since my current programming level doesn't allow me to contribute and help solving the issue. I could move to Ubuntu, so staying on Windows is my personal choice and there are consequences I must live with.

However, I still wonder: isn't basically every Windows likely to meet this issue? Can it reasonably be said that yarn supports Windows since the bug is around since last October?

If it's bleeding edge, half-skilled amateur dev like me could maybe be warned to stay away for now.

@Daniel15
Copy link
Member

Submitted a diff to fix this: #3233

Can it reasonably be said that yarn supports Windows since the bug is around since last October?

The bug only affects global packages, which are very rarely used compared to regular (local) packages. The only use case for global packages is for things that are not specific to one project (for example, scaffolding tools like create-react-app and yeoman). Almost everything else is specific to a project and thus should go into that project's package.json file as a dependency.

@ghost
Copy link

ghost commented Apr 23, 2017

By the way, I found a workaround that worked on my pc: use chocolatey to install yarn (as proposed on the yarn website).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants