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

Support for Yarn global #8

Closed
tunnckoCore opened this issue Oct 9, 2017 · 8 comments
Closed

Support for Yarn global #8

tunnckoCore opened this issue Oct 9, 2017 · 8 comments

Comments

@tunnckoCore
Copy link

tunnckoCore commented Oct 9, 2017

Hey there. Just found that it not works for yarn global path.

Which i believe isn't configurable or?

If that's right, then it is /home/<username>/.config/yarn/global/node_modules

@tunnckoCore
Copy link
Author

This comment may help yarnpkg/yarn#2049 (comment)

@tunnckoCore
Copy link
Author

Looking at global-prefix... is that process.env.APPDATA that %LOCALAPPDATA% 😆 I'm not familiar with windows much..

I can PR immediately if get a bit clarification.

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 14, 2018

Hey @jonschlinkert, @doowb help?

@jonschlinkert
Copy link
Owner

I don't know a lot about how yarn does global caching (I haven't used it in a long time), but as I recall packages aren't installed globally the same way as npm.

Doesn't yarn add global packages to sub-directories that are named with hashes (or something similar) to guarantee deterministic installs? If so, how would the global yarn folder even be useful? Would you be able to find the packages you need without globbing or recursing over all the folders? (I might be totally wrong and missing the point. Like I said I haven't used it in a while. Sorry if I'm overcomplicating it)

@tunnckoCore
Copy link
Author

tunnckoCore commented May 11, 2018

Heya. Progress here.

Doesn't yarn add global packages to sub-directories that are named with hashes (or something similar) to guarantee deterministic installs?

Actually no. It has .yarn-integrity file in its node_modules folder.

~/.config/yarn/global/
~/.config/yarn/global/package.json
~/.config/yarn/global/yarn.lock
~/.config/yarn/global/node_modules/
~/.config/yarn/global/node_modules/.yarn-integrity

Which integrity file seems to has that info for the determinism. Actually that global folder is treated as any other package - it has package.json and yarn.lock file.

.yarn-integrity file starts like that

{
  "systemParams": "linux-x64-64",
  "modulesFolders": [
    "node_modules"
  ],
  "flags": [],
  "linkedModules": [
    "charlike-cli"
  ],
  "topLevelPatterns": [
    "bithound@^1.7.0",
    "bolt@^0.20.6",
    "charlike-cli@^0.3.6",
    "gitclone-cli@^1.0.1",
    "gtop@^0.1.5",
    "staticland@^3.2.2",
    "verb-generate-readme@^0.6.0",
    "verb@verbose/verb#dev",
    "vmd@^1.33.0"
  ],
  "lockfileEntries": {
    "@types/node@^8.0.24": "https://registry.yarnpkg.com/@types/node/-/node-8.0.46.tgz#6e1766b2d0ed06631d5b5f87bb8e72c8dbb6888e",
    "JSONStream@^1.3.2": "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea",
    "abbrev@1": "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8",
    "abbrev@~1.1.1": "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8",
    "agent-base@4": "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce",
    "agent-base@^4.1.0": "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce",
    "agentkeepalive@^3.3.0": "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-3.4.1.tgz#aa95aebc3a749bca5ed53e3880a09f5235b48f0c"
  }
}

I don't think we need the cache or offline storage, so according to the linked comment above it would be easy change.

@tunnckoCore
Copy link
Author

tunnckoCore commented May 11, 2018

Actually we should transfer this issue to the global-prefix?

edit: actually no, because we cant treat it as prefix, so should be handled here. We should detect if there is yarn first and then continue? Or even more better would be to just export a function and allow passing options like {yarn: true}.

The only way that i can see this fixed is calling yarn directly to get the paths, but that may be not wanted weight? BUt in same time, it be only behind options, so no breaking changes and no problems for users. And for the Yarn case it should be compromise.

~
❯ yarn global bin 
/home/charlike/.yarn/bin

~
❯ yarn global dir
/home/charlike/.config/yarn/global

Neither of them are configured specifically. Yarn was just installed through npm.

edit 2: Another fix would be to open PR/issue in Yarn to set env variables through the postinstall step, such as i was added in my zsh YARN_GLOBAL_BIN env.

@jonschlinkert
Copy link
Owner

@tunnckoCore
Copy link
Author

Cool! Didn't noticed them. I should wrap the things around yarn-global-modules then.

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

2 participants