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

Why is yarn a direct dependency? #71

Closed
ahmedelgabri opened this issue Mar 18, 2019 · 12 comments
Closed

Why is yarn a direct dependency? #71

ahmedelgabri opened this issue Mar 18, 2019 · 12 comments

Comments

@ahmedelgabri
Copy link

ahmedelgabri commented Mar 18, 2019

Any specific reason behind that?

"yarn": "^1.13.0"

This can cause lots of issues, if a package that depends on plugin-plugins is installed globally yarn will then symlink everything in the global node_modules/.bin to /usr/local/bin in this case your yarn version will override the system yarn version.

@ahmedelgabri ahmedelgabri changed the title Why is a yarn a direct dependency? Why is yarn a direct dependency? Mar 20, 2019
@calavera
Copy link

is this a valid suggestion @ahmedelgabri ?

That's a tough one, I understand that @oclif/plugin-plugins uses yarn internally. But also overriding system installed yarn is 100% not desired. Maybe they should move it as a peerDependency or something.

@ahmedelgabri
Copy link
Author

I dunno to be honest, peerDependencies also comes with its own set of issues, on top of my head if someone updated their yarn to a new version that's not compatible with the package then the package will not work. Which then reflect badly on the package authors & the package itself.

Maybe we should ask someone from the yarn team on what would they recommend. Because I see this issue becoming bigger once yarn v2 is released.

@jdx
Copy link
Contributor

jdx commented Mar 20, 2019

npm doesn't behave like you describe:

$ ll /usr/local/bin/yarn
"/usr/local/bin/yarn": No such file or directory (os error 2)
$ npm i -g @oclif/plugin-plugins
+ @oclif/[email protected]
added 74 packages from 28 contributors in 3.358s
$ ll /usr/local/bin/yarn
"/usr/local/bin/yarn": No such file or directory (os error 2)
$ ll /usr/local/bin/yar^C
$ npm i -g yarn
/usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js
/usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js
+ [email protected]
added 1 package in 0.145s
$ ll /usr/local/bin/yarn
Permissions Size User    Date Modified Name
lrwxr-xr-x    36 jdickey 20 Mar  9:10  /usr/local/bin/yarn -> ../lib/node_modules/yarn/bin/yarn.js

@jdx
Copy link
Contributor

jdx commented Mar 20, 2019

Neither does yarn:

$ yarn global add @oclif/plugin-plugins
yarn global v1.13.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
warning "@oclif/[email protected]" has no binaries
✨  Done in 1.74s.
$ ~/s/g/o/plugin-plugins   master  cd ..
$ ~/s/g/oclif  ll /usr/local/bin/yarn
"/usr/local/bin/yarn": No such file or directory (os error 2)

@ahmedelgabri
Copy link
Author

@jdxcode You are right, I tried this again now & it's not happening. I'll try again & check if I can replicate it again or if it has something to do with my local setup or $PATH or something.

I updated yarn though today so not sure if that has anything to do with that. But will see.

@ahmedelgabri
Copy link
Author

@jdxcode can you run these and post the output?

yarn global bin & yarn global dir

@jdx
Copy link
Contributor

jdx commented Mar 20, 2019

$ yarn global bin
/usr/local/bin
$ yarn global dir
/Users/jdickey/.config/yarn/global

@ahmedelgabri
Copy link
Author

Ok, I don't think it's yarn issue. But also can't find the root cause yet

I had issues way back with yarn symlinking binaries to /usr/local/bin so I had this /Users/ahmed/.config/yarn/global/node_modules/.bin in my $PATH but, my yarn global dir returns /Users/ahmed/.local/share/yarn/global though, without changing any setting or anything for yarn & there is no /Users/ahmed/.config/yarn/global folder on my system. So even the path in my $PATH can't cause this issue.

I'll close the issues I created & will investigate this more. Thanks everyone & sorry for the inconvience.

@bk3c
Copy link

bk3c commented Aug 15, 2019

FWIW, I've been struggling with the effects of this for a few months, and finally figured it out enough to find this issue. I'm pretty sure I have a reproducible case, though I can't tell if this is actually yarn being broken or misused:

  • my system yarn is via homebrew
  • I have two globally installed packages that depend on this one (apollo and netlify-cli), and this is the only global dependency I have on yarn
  • if I wipe my global yarn.lock and node_modules and reset all of the symlinks, I can do a yarn add to recreate both with no problems at all
  • as soon as I do a yarn global upgrade or yarn global upgrade-interactive, the symlinks in /usr/local/bin are overwritten and now point to ~/.config/yarn/global/node_modules/.bin/yarn
  • this is 100% reproducible, at least in my environment
  • it's super-annoying

Would y'all consider removing the dependency, or do we need to go file a yarn issue? Can you see if this is enough for you to reproduce the issue?

@ahmedelgabri
Copy link
Author

I just tried this & that's exactly my issue too. @bk3c I can reopen this yarnpkg/yarn#7132 & you can add your comments there as I think it might be more of a yarn issue

@bk3c
Copy link

bk3c commented Aug 16, 2019

@ahmedelgabri Sounds good to me.

@mhnsn
Copy link

mhnsn commented Jan 26, 2022

Fun fact: this borks HARD on Windows if you explicitly have script-shell=pwsh in .npmrc. You get this lovely syntax in the yarn preinstall script: pwsh -c :; (node ./preinstall.js > /dev/null 2>&1 || true). Found this out the hard way just now while trying to run oclif generate <my-cli> and then running npm i in the generated folder. I'll add the comment in the yarn issue as well.

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

5 participants