-
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.lock gets updated by collapsing dependencies when there is no need to #3315
Comments
I think I am running into this same issue. It def. seems weird that it's shuffling dependencies when the resultant dependency tree is identical, but I think this comment might also apply here: @kittens, @thejameskyle, sorry for digging up an oldy, but is what you meant by this comment: … that a Also, sorry for hijacking this ticket. Happy to be directed to a better place for this discussion. |
I am running into the same issue, which results in my Build Tooling (create-react-app/react-scripts fork) breaking whenever I add a new dependency or run A workaround for me was downgrading yarn to v0.21.3. |
I'm running into this too. Some context: I currently work from 2 different laptops (work & home, same config, same versions of yarn & node) on two branches (say "master" & "work" with work having some new deps not in master yet). Executing Example of change I see: -lodash@4.12.0, lodash@4.x.x, lodash@^4.0.0, lodash@^4.0.1, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0:
+lodash@4.12.0, lodash@^4.0.0, lodash@^4.2.0:
version "4.12.0"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.12.0.tgz#2bd6dc46a040f59e686c972ed21d93dc59053258"
-"lodash@>=3.5 <5", lodash@^4.14.0, lodash@^4.15.0, lodash@^4.16.4, lodash@^4.17.2:
+lodash@4.x.x, "lodash@>=3.5 <5", lodash@^4.0.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.16.4, lodash@^4.17.2, lodash@^4.2.1, lodash@^4.3.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" And on a later run (after switching back and forth from a branch, or switching of laptop ( Here is my expectation on executing And given this part taken as example:
Now for generating this yarn.lock file, it seems it lacks a deterministic way of choosing what requirement is mapped to what version. I expect when doing Now, looking at the "requirement line" of a version, it must have a deterministic order (alphabetical, logical somehow...) From my example, after an upgrade resulting in adding a new version of lodash (say 4.17.5), the yarn.lock file should move to:
and be stable (unless lodash is upgraded, or a dependency requirement on lodash changes). What do you think ? Was that the plan ? |
This got fixed in #3477 and released in 0.26 this Friday. |
having the same problem with the latest version. |
@calidion, could you post repro steps in a separate issue? |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When running
yarn
(install), the yarn.lock file gets rearranged when there is no need to.If the current behavior is a bug, please provide the steps to reproduce.
I have found the following package.json to create different yarn.lock files on different machines.
Since yarn's heuristics around collapsing duplicates seems dependent on your current local cache, it is somewhat difficult to reproduce. The best way I have found is:
$ yarn
$ mv "$(yarn cache dir)" "$(yarn cache dir)-save"
$ \rm -rf node_modules
$ yarn && git diff
You can find an example here: https://travis-ci.org/atomist/travis-rugs/builds/228523519#L382
The line linked to is the invocation of
yarn --frozen-lockfile
(the fact that the--frozen-lockfile
argument is ignored is discussed here #3313 ) and subsequentlygit diff
is run. You can see from the diff output that the only changes are collapsing of duplicate versions into a single version that satisfies all the constraints.This leads me to think the problem has arisen recently with the work around collapsing duplicate dependencies, see #579 . Thus, this issue seems different than #570, #1576, and #2023 (which turned out to be a non-issue), aside from the fact that those issues are closed and this problem occurs with the latest version of yarn.
What is the expected behavior?
Per #570 (comment) , if the current yarn.lock file satisfies the package.json file, I expect yarn to install the packages according to the current contents of the yarn.lock, not update and rewrite yarn.lock with an equivalent alternative.
Please mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: