-
Notifications
You must be signed in to change notification settings - Fork 170
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
npm install -g yarn #6
Comments
|
Because
That's fine, except that in the pmm case the binaries are already there, and already point to something:
Since npm isn't aware of this, when running
Since the "new" symlink is different from the old one, npm fails with the aforementionned error, refusing to overwrite the symlink (which is the correct thing to do - you wouldn't want
The notion of what is an upgrade in the context of pmm is part of what this issue is about. If It might be an acceptable course of action (although it would require a change on npm's side to let it know that overriding the pmm binaries is fine), but I'm curious what other people think. I personally could see it being a good option for a few years, since it's low-friction with existing workflows, but in this case I'd prefer npm to also print a warning explaining what just happened, and how to reverse it (at the moment it would corrupt the Node install forever, as |
Couldn't yarn have a postinstall script to detect this case and repair it, without needing any changes in npm or node? |
That's an interesting idea - it probably could, but I believe it would still require to at least make npm override the existing symlink if it's a pmm one (otherwise it'll hit the EEXIST before calling the postinstall). At this point, the same PR could probably add pmm symlink restoration on uninstalls to npm. |
I've made a small hack in Yarn 1.22.7 which should magically make it compatible with Corepack (new name for pmm). While the |
Of note, it won't be enough if the users have installed Node as root: yarnpkg/yarn#8358 |
This issue should be reopened, I believe. npm v7 will stubbornly refuse to install top-level global packages if a bin already exists by the same name as one that they're trying to create. If it knows that the bin linking will fail, then it won't unpack the dep or run any scripts for it. Again, my apologies for not catching this sooner. Some options I can imagine:
|
aws-lambda-nodejs have issue * [npm install -g yarn · Issue #6 · nodejs/corepack](nodejs/corepack#6) * [npm install yarn --global fails in docker container · Issue aws#8358 · yarnpkg/yarn](yarnpkg/yarn#8358) From issue comment, > For future reference, you can (should) pin your version rather than use whatever the latest is on npm (by using yarn@1.22.6, etc) - it's a good practice anyway regardless of the conditions, as you never know which bug could slip by us. You can also use the yarn-path setting to ensure that upgrades go through the appropriate review processes (including CI). > > <yarnpkg/yarn#8358 (comment)> So we'll follow it. And from issue comment, > Fwiw we don't plan to add any more features to Yarn 1, as all of our resources have shifted to Yarn 2. The past few commits have been aimed toward making the transition a bit easier, in particular thanks to the Corepack initiative which we hope will make it easier to use Yarn (both 1 & 2) by removing the need to manually install them. > > <yarnpkg/yarn#8358 (comment)> There's not much need to be concerned with the latest version of 1.
fixes #10881 # fix from sh to bash `lib/bundlers.ts` actually uses not `sh` but `bash`, `bash` is a good way to test. # lock yarn version aws-lambda-nodejs have issue * [npm install -g yarn · Issue #6 · nodejs/corepack](nodejs/corepack#6) * [npm install yarn --global fails in docker container · Issue #8358 · yarnpkg/yarn](yarnpkg/yarn#8358) From issue comment, > For future reference, you can (should) pin your version rather than use whatever the latest is on npm (by using yarn@1.22.6, etc) - it's a good practice anyway regardless of the conditions, as you never know which bug could slip by us. You can also use the yarn-path setting to ensure that upgrades go through the appropriate review processes (including CI). > > <yarnpkg/yarn#8358 (comment)> So we'll follow it. And from issue comment, > Fwiw we don't plan to add any more features to Yarn 1, as all of our resources have shifted to Yarn 2. The past few commits have been aimed toward making the transition a bit easier, in particular thanks to the Corepack initiative which we hope will make it easier to use Yarn (both 1 & 2) by removing the need to manually install them. > > <yarnpkg/yarn#8358 (comment)> There's not much need to be concerned with the latest version of 1. # allow execute command for non root user `amazon/aws-sam-cli-build-image-nodejs12.x` don't have user that index is 1000. So create non root user. `/` in `amazon/aws-sam-cli-build-image-nodejs12.x` permission is `700`. change to allow execute command for non root user. I really don't want to change around the permissions, but I don't have a choice. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
With pmm currently installed, the following currently happens when running
npm install -g yarn
:There are a few options on the ideal behavior:
Ask npm to assume
--force
when overriding theyarn
binary (or any other binary covered by pmm). Pros, it preserves the current behavior, anyone who runsnpm install -g yarn
can keep doing it without changing their workflows. Cons, it means that they would effectively be replacing the pmm binary, so they wouldn't benefit from the "ensures the right version" anymore.Ask npm to exit with a zero exit code when it detects that the
yarn
binary points to pmm, and print a message explaining the situation with a link to the pmm project. Perhaps we could also make it change the default Yarn version that pmm would use for new projects. Pros, people can keep using their workflow, they don't accidentally overwrite their binaries and lose features. Cons, it's a bit magical, might be confusing to some users.Decide that this is the expected behavior, and that people upgrading to Node 15.x are expected to be aware that running
npm install -g yarn
isn't needed anymore. Potentially ask npm to improve the error message to explain the situation. Pros, fail early, this would make this improvement noticeable. Cons, it's maybe too noticeable, and CI providers would need to adapt to this change.For reference, the ideal message I mention would be akin to:
With the url pointing to longer explanations.
The text was updated successfully, but these errors were encountered: