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

Fix global module executable path on Windows #3233

Merged
merged 1 commit into from
Apr 24, 2017

Conversation

Daniel15
Copy link
Member

Summary
Node.js is almost always installed in C:\Program Files\Yarn, which regular users can't write to. However, Yarn defaults to installing the executables for global modules in the Node directory. This means that the out-of-the-box experience for people installing global modules on Windows is totally broken.

It should instead place them in a directory that the user can write to. I'm going with %LocalAppData\Yarn\bin (eg. C:\Users\Daniel\AppData\Local\Yarn\bin) as it makes the most sense given all the config and cache is already in that directory. I also updated the path in the installer, as the path the installer was using didn't actually exist (.bin instead of bin).

Test plan

Tested bin\yarn global add webpack, it placed the files in the right directory:

Closes #3055

@DustinKingen
Copy link

DustinKingen commented Apr 23, 2017

Can confirm the additional if statement fixes the issue. Not sure whether changing .bin -> bin is a breaking change. I noticed that the .bin folder is not created after installing yarn. I had to manually add the folder to AppData\Local\Yarn. Yarn will need to ensure .bin or bin exists so that scripts installed with yarn global will be available on the path.

@Daniel15
Copy link
Member Author

Not sure whether changing .bin -> bin is a breaking change

.bin never actually existed, so that should be fine.

@Daniel15
Copy link
Member Author

Just realised this is broken for non-root users on Linux too... Need to fix that as well.

test@a5cf448820fd:/tmp/lol$ /yarn-src/bin/yarn global add create-react-app
yarn global v0.24.0-0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-react-app
error We don't have permissions to touch the file "/usr/bin/create-react-app".
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

@bestander bestander merged commit 5fc8539 into yarnpkg:master Apr 24, 2017
@Daniel15 Daniel15 deleted the module-location branch April 30, 2017 02:19
@DanBuild DanBuild mentioned this pull request May 2, 2017
@gaearon
Copy link
Contributor

gaearon commented May 12, 2017

Thanks for the fix.

@wtchangdm
Copy link

Sorry for asking question here, is the PATH environment variable added only when yarn was installed by Windows Installer and not by npm?

@Daniel15
Copy link
Member Author

Daniel15 commented May 27, 2017 via email

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

Successfully merging this pull request may close these issues.

5 participants