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

Fixes unwanted yarn.lock optimization issue #3490 #3729

Merged
merged 2 commits into from
Jun 27, 2017

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Jun 26, 2017

Summary

This PR aims to prevent the lockfile from being optimized when reading it. If a package isn't "fresh" (ie if it's present in the lockfile), we resolve it to the exact version registered in the lockfile.

Test plan

I haven't been able to come up with a minimal testcase that could be used with the integration tests :/ I used the following repository to test my changes, but it brings a lot of dependencies and some of them don't seem to work in the tests (got this apparently unrelated error: error "neutrino#optional" is wrong version: expected "0.1.3", got "v0.1.3").

$> git clone https://github.com/timkelty/yarn-order-bug
$> yarn
$> git diff yarn.lock

The last line should print nothing, but before this patch it was optimizing the diff.

@arcanis arcanis requested review from BYK and bestander June 26, 2017 14:30
@BYK
Copy link
Member

BYK commented Jun 26, 2017

Why not make --frozen-lockfile default to true instead?

@arcanis
Copy link
Member Author

arcanis commented Jun 26, 2017

I thought about this, but:

  • Frozen lockfiles will throw an error if their lockfiles need to be updated (ie if a resolved package is "fresh"). We don't want this behavior. Furthermore, if there's no lockfile at all, we still want to write it (at least for now, otherwise we would be breaking peoples' workflow in a minor).

  • Pure lockfiles will not write their lockfiles either, even if there's none.

This PR also ships with a fix (the resolvedRange thing) to instruct Yarn to use the same references when resolving the same version. Without it, it yells a lot of warnings (thankfully nothing really break) because it thinks that multiple packages are trying to unpack into the same directory.

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@BYK
Copy link
Member

BYK commented Jun 26, 2017

Please use a more descriptive commit title before merging.

@bestander
Copy link
Member

+1 about descriptive title, I'll help you with this one.
Also I think you need to add "fixes #3490" to the PR description so that Github closes the associated issue automatically and people were able to navigate to the issue with a click (the #3490 in title is not clickable)

@bestander bestander changed the title Fixes #3490 Fixes unwanted yarn.lock optimization issue #3490 Jun 26, 2017
@bestander
Copy link
Member

We need tests for this, @arcanis.
I understand that it will be a waste of time to hand-craft the test, so just add an integration test from https://github.com/timkelty/yarn-order-bug.
We'd better pay the price of extra 20s on test runtime than have this issue return back.

@bestander
Copy link
Member

Ideas for tests:

  1. https://github.com/timkelty/yarn-order-bug indeed looks rathe large, if you can express it in install operations then good.

  2. There is a test case in this branch https://github.com/yarnpkg/yarn/pull/3563/files, just cherry-pick it and verify that your PR fixes it

@bestander
Copy link
Member

@BYK, regarding --frozen-lockfile being default, there is an early discussion here #570.

I raised the issue but was convinced that we can drop lockfile strictness when package.json is manually updated.
In all other cases Yarn should definitely not update lockfile without a warning.

@bestander
Copy link
Member

This looks promising, @arcanis.
How is it related to #3673, can we return concurrent resolution?

@arcanis
Copy link
Member Author

arcanis commented Jun 26, 2017

@bestander I'm not completely sure regarding #3673 - I think it should work, but I'll have to test it manually later. Once this patch is ok'd I'll publish the 0.27.1 - David is needing the link: feature, so I'd like not to block him too long. After that, I'll make some tests with adding back the async behavior :)

@arcanis
Copy link
Member Author

arcanis commented Jun 26, 2017

Working on the tests, btw 👍

@bestander bestander mentioned this pull request Jun 26, 2017
@arcanis
Copy link
Member Author

arcanis commented Jun 26, 2017

Should be ok 👍

@arcanis arcanis force-pushed the no-optim-default branch from 199bd5c to 83cfafa Compare June 26, 2017 18:14
@arcanis arcanis merged commit 5152bd7 into yarnpkg:master Jun 27, 2017
arcanis added a commit that referenced this pull request Jun 27, 2017
* Resolves non-fresh-packages with the exact version specified in the lockfile if possible, fixes #3490

* Adds a test
@bestander bestander mentioned this pull request Jun 30, 2017
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

Successfully merging this pull request may close these issues.

3 participants