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

Redirect "global" yarn directory #2969

Closed
wants to merge 1 commit into from

Conversation

milang
Copy link
Contributor

@milang milang commented Jan 9, 2019

Current installer for yarn redirects bin, cache and mirror directories to scoop's persistent storage. However, the global directory (used by packages that get installed globally via yarn global add) is still using the default $env:LOCALAPPDATA\Yarn\Data\global.

This pull request adds a persistent directory global and then updates .yarnrc to use it.

Unfortunately yarn does not currently recognize global-folder configuration setting, only --global-folder (source), so I added an extra post-install PowerShell fragment that adds the -- prefix to global-folder in .yarnrc file.

The following screenshot illustrates the difference in yarn global dir output when using installing the current yarn bundle and when installing updated bundle (as per this PR):

yarn global dir

@milang
Copy link
Contributor Author

milang commented Jan 11, 2019

@r15ch13 any comments?

@eteeselink
Copy link

@milang I'm just a random guy from the internet. I like Scoop and I noticed there's many PRs so I figured I could spend a few minutes helping with code reviews. I have no Scoop authority whatsoever.

I think the code behind this change is good, but I'm not sure what the practical problem is with Yarn's global directory remaining in $env:LOCALAPPDATA\Yarn\Data\global. Isn't the whole point of it that it remains in place across updates?

I understand that it would be neater if it's all managed in scoop's persistent storage, but it also adds complexity. Did you write this just for neatness, or is there a practical problem with Yarn managing its own global storage behind Scoop's back?

@chawyehsu
Copy link
Member

chawyehsu commented Jan 22, 2019

That's a matter of choice, it's neat that redirecting it to scoop's persistent storage, but as you said, it adds complexity.

I don't care about the problem that some apps do have behavior outside Scoop's folder, so just keeping yarn's default global location is always a better idea to me.
https://github.com/h404bi/dorado/blob/master/bucket/yarn.json#L17-L22

I can't force every Scoop user to do that, so making a variant manifest for yourself is a better choice, that's a highlight feature of Scoop. Make Scoop fit your need!

P.S. Changing yarn's global location can cause problem #1641

@rasa
Copy link
Member

rasa commented Feb 8, 2019

This change seems reasonable, but I don’t use yarn. Are there any downsides to merging this in?

@eteeselink
Copy link

I see one downside and one risk:

  • downside: it adds complexity
  • risk: will this work correctly across upgrades? people who upgrade yarn will already have a yarn global folder outside the scoop tree. i feel like it'd need a lot of careful testing.

Finally, while I can see that this PR has been a lot of work to make, and the code itself looks fine, I still don't know what problem it solves. If it's just the aesthetics of not having a Yarn folder outside the Scoop tree then I'm against merging this in for the above-mentioned downside and risk. But maybe there's a different problem that I fail to see. @milang can you chip in?

(note: i am just a guy from the internet, my opinion should not weigh particularly heavily)

@niheaven
Copy link
Member

I've made a PR in upstream (yarnpkg/yarn#7056) that add global-folder support in .yarnrc, and since yarn global binshim has some problems and is not fixed recently, I suggest use global-folder\node_modules\.bin instead.

When the upstream PR is not merged, maybe a hardcoded fix to yarn is better then hardcoded fix to install script in scoop manifest. I'll try to make one (a simple -replace doesn't work).

r15ch13 pushed a commit that referenced this pull request Mar 18, 2019
- Yarn's global folder can be set via `yarn config set global-folder` (yarnpkg/yarn#7056) and thus can be persisted. 
- ~~Since yarn's global bin creating procedure is still problematic (yarnpkg/yarn#6902, **fixed by yarnpkg/yarn#6954 The `.bin` folder in `global\node_modules` is a better path to add to env, and this can avoid the annoying problem when you install scoop in some place except `C:` (that the shims in global bin have wrong relative path pointer).
- If you install yarn via `scoop install yarn`, the `Yarn` folder in `$env:LOCALAPPDATA` is useless, and when you uninstall `yarn`, the `.yarnrc` is unused, so the manifest add `uninstaller.script` to remove them when you uninstall.
- For reconfiguration, please use `scoop update yarn -f` instead of `scoop reset yarn`.

- Close #2969
@milang
Copy link
Contributor Author

milang commented Mar 19, 2019

Thank you @niheaven, your fix is much better.

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.

None yet

5 participants