-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Yarn upgrade creates duplicate dependency resolution #3967
Comments
Hi @xdumaine, thanks for creating a separate issue for this! Would you mind providing us an isolated, reliable reproduction script so we can test this quickly? Even a very simple Thanks! |
@BYK This repo has a package.json and yarn.lock which will reproduce it. Just check it out, and run |
Note that the results for removing |
I can confirm the behaviour described by @xdumaine still occurs on Yarn v1.0.2. The only workarounds I know of are:
|
@BYK can you please update the labels on this so that it will maybe get fixed? |
@xdumaine I didn't have time to look into this more yet. Will update the labels once I confirm and know where to look. |
The current workaround we do is deleting node_modules and yarn.lock and running yarn again. |
Updating jsdoc to 3.5.5 didn't solve the problem with node 8.5 just because of a yarn bug (yarnpkg/yarn#3967) creating package duplicates: gulp-jsdoc still used the old jsdoc 3.5.4. Deleting `node_modules` and `yarn.lock`, then running `yarn` helps to get rid of package duplicates. Is yarn really better than npm?
I recently experienced this same behavior with Yarn 1.1.0 in a project and the workaround of deleting I can't however reproduce the issue by running The issue seems to be one of a faulty deduplication – where running a |
@voxpelli run It's currently still reproducible on yarn 1.1.0 if you do a targeted version upgrade that matches the current package.json range. So |
I can confirm that Though core issue was about Because issue with just |
The issue was around upgrading a specific package |
@voxpelli That issue is marked as resolved, but this still occurs on the latest version of yarn. |
@wycats This is a major roadblock to us using yarn with ember, and I think it'll cause a lot of problem with projects on 2.16 and module unification because there will be may more dependency trees that look like this. |
@xdumaine I've updated your issue to make it clear how to reproduce the issue consistently and what is the expected outcome. Please correct any mistakes you see in them and try to provide exact steps, independent of time to reproduce the issue consistently since I had to read the whole thread to both reproduce the issue and see what to look for in the lock file to understand what is going on. I agree that this is an important issue to resolve. If this is also a big deal for you, try submitting a PR that fixes it? Even submitting a PR with only a failing test case would help someone else get started on the issue. |
This occurs in our repos as well. The latest versions of yarn (>1.0?) do not correctly resolve transient dependencies, and create duplicates. For example; our application's package.json pulls in react "^15.6.1" and many of our modules pull in react "^15.6.1 || ^16.0.0". When we delete the yarn.lock and node_modules folder, then run yarn, it generates a yarn lock with both react version "15.6.2" and "16.1.1". In earlier versions of yarn, and our preferred outcome, it should only include version "15.6.2" because that satisfies both dependencies and duplicate packages (especially react) cause all sorts of weird issues and larger bundle sizes when built with webpack. We also used to use "yarn upgrade" and "yarn upgrade-interactive" but it stopped working for us because we have been seeing the same behavior. Basically, it seems like it no longer re-runs the entire dependency resolution after upgrading a package, and leaves duplicates (dependencies of dependencies) in the node_modules folder, only upgrading the top-most version of that package. |
You might want to try https://www.npmjs.com/package/yarn-tools to automatically deduplicate the lockfile. |
@scinos we really shouldn't have to use a package to fix the package manager. Yarn has de-dupe commands built in if you use the 'flat' lockfile, but in this scenario, the base behavior is broken. |
This looks like intended behavior according to #79. I think there even is a code snippet that explicitly ensures it: code // don't optimize things that already have a lockfile entry:
// https://github.com/yarnpkg/yarn/issues/79
const collapsablePatterns = patterns.filter(pattern => {
const remote = this.patterns[pattern]._remote;
return !this.lockfile.getLocked(pattern) && (!remote || remote.type !== 'workspace');
});
if (collapsablePatterns.length < 2) {
return;
} If this is indeed a bug it should be easy to fix. Just remove the @BYK With special regards to #79, can you please (again) confirm that this is a bug and that it is legitimate to fix it with the proposed changes. |
This issue has not been fixed? |
Status "Open" of an issue means "not fixed". |
I really set myself up there, didn't I? I was so tired. My apologies. I didn't mean to write a comment at all. |
I can confirm that temporarily adding the dependency to [edit: or just use yarn-deduplicate] |
Use yarn-deduplicate |
Or |
Can confirm this is still a thing in |
Reading through this issue to understand the current status, it seems like we're waiting for a reply to #3967 (comment). /cc @BYK Upgrading dependencies is a frequent task, and it's a real pain to have to remember to use one of the mentioned workarounds ( A large number of people have upvoted this issue, so I think it's really important that we get this fixed? |
@OliverJAsh thanks for the useful heads up. I'd say this behavior makes sense when running Maybe we can add a new flag, |
i use rush + yarn
// webpack@^4.0.0 by deps from vue-cli I don’t know the problem in yarn or in rush yarn, but in 3 days I could not find a workaround for this problem. |
Still same behaviour in yarn 1.21.1
run
|
Yarn 2 has been released. Base on Yarn 2 roadmap and #579 , this issue should be fixed in Yarn 2. You can install Yarn 2 by following this guide |
https://www.npmjs.com/package/yarn-deduplicate is still the answer for yarn < 2 |
@ocavue |
Are you sure? I see only RC releases, not stable. |
|
OK, big words, but be aware: on the https://yarnpkg.com/package/yarn I see: RC can be quite stable, but it's not stable release, it's "release candidate". I have questions to Yarn v2 release actions (updated site for RC), but this issue not about that. |
Adds automation for updating the pu/pu node dependency. This also adds tools for deduplicating entries in the yarn.lock file. Those sometimes happen when upgrading dependencies... :( yarnpkg/yarn#3967
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I have a dependency tree like this
And when I
yarn upgrade shared-dep
(say when 1.2.0 is released) it causes duplication in yarn.lock where the resolution forshared-dep
doesn't change for the version pulled in by dep-1 and dep-2 and it adds a new (duplicate) resolution for shared-dep so that now it's pulling in 1.1.0 and 1.2.0.Before upgrade:
After upgrade:
If the current behavior is a bug, please provide the steps to reproduce.
yarn upgrade commander@^2.4.0
yarn.lock
file has two overlapping entries for commander:What is the expected behavior?
Having a single
commander
entry in the lockfile:Please mention your node.js, yarn and operating system version.
OS X 10.12.5
node v8.9.0
yarn v1.3.2
The text was updated successfully, but these errors were encountered: