Yarn: Resolutions interfere with the integrity check for `yarn install`

Created on 18 Jan 2018  ·  4Comments  ·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When using resolutions, yarn install doesn't bail out early if the installation is already up-to-date.

If the current behavior is a bug, please provide the steps to reproduce.
Create a package, and specify a resolution (example repo). Run yarn install in the package. Run yarn install again, which will go through all the installation steps instead of bailing.

With some tracing, I found that the integrity check fails with LOCKFILE_DONT_MATCH because the resolution pattern exists in the lockfile on disk, but not in the cached lockfile. Apparently, the resolution pattern is getting deleted from the cached lockfile by the PackageResolver before the integrity check. Removing the linked line from the PackageResolver fixes the integrity check issue, and the tests pass. However, I haven't yet figured out the original reason for removing the resolution pattern from the lockfile, so maybe the conditional on the preceding line should be changed instead?

What is the expected behavior?
When using resolutions, yarn install should bail out early if the installation is already up-to-date.

Please mention your node.js, yarn and operating system version.
yarn 1.3.2 (and 1.4.0)
node 9.3.0
linux 4.14.13 x86_64

triaged

Most helpful comment

@kaylieEB you did reproduce this. your second yarn install went through all the stages and ended up Saving lockfile though all it had to do was to say that it's already synced

All 4 comments

yes! can confirm. was just going to file the same issue.

Hi @edyburn , I can't see to repro
```integrity-example.git⑂master 🦊 git clone https://github.com/edyburn/yarn-resolutions-
Cloning into 'yarn-resolutions-integrity-example'...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (7/7), done.
Unpacking objects: 100% (10/10), done.
remote: Total 10 (delta 1), reused 10 (delta 1), pack-reused 0
~/playground/testing ⑂master* 🦊 cd yarn-resolutions-integrity-example/
~/playground/testing/yarn-resolutions-integrity-example ⑂master 🦊 yarn
yarn install v1.4.1
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
success Saved lockfile.
✨ Done in 1.02s.
~/playground/testing/yarn-resolutions-integrity-example ⑂master 🦊 yarn
yarn install v1.4.1
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
success Saved lockfile.
✨ Done in 0.25s.

~/playground/testing/yarn-resolutions-integrity-example ⑂master 🦊 ls
README.md node_modules package.json yarn.lock

~/playground/testing/yarn-resolutions-integrity-example ⑂master 🦊 yarn check
yarn check v1.4.1
success Folder in sync.
✨ Done in 0.20s.
```
Also that line is needed because we need to override the existing lockfile entry when a resolution field is entered.

@kaylieEB you did reproduce this. your second yarn install went through all the stages and ended up Saving lockfile though all it had to do was to say that it's already synced

Fixed by #5572. Thanks @MhMadHamster!

[yarn-resolutions-integrity-example]$ yarn
yarn install v1.6.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.25s.
[yarn-resolutions-integrity-example]$ yarn
yarn install v1.6.0
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.10s.
Was this page helpful?
0 / 5 - 0 ratings