-
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 install --frozen-lockfile
exits with error, but yarn install
does nothing afterwards
#4778
Comments
From a quick glance, it looks like for some reason Yarn is reporting that
I'll continue digging in ... |
More research notes: It looks like what happens is that:
This is because the
If you delete the Summary: looks like a bug in the interaction between "resolutions" and frozen-lockfile. |
…solution (#4793) **Summary** Fixes #4778. In this particular issue, the same pattern `babel-runtime@^6.26.0` was [defined in both devDependencies](https://github.com/kompot/yarn-frozen-lockfile-bug/blob/master/package.json#L80) and [resolutions field](https://github.com/kompot/yarn-frozen-lockfile-bug/blob/master/package.json#L130). Since resolutions feature was only intended for nested dependencies, it previously didn't take into account when the same exact pattern existed as a top level dependency. And it happens so that after the package resolver phase, [integrity checker looks at top level patterns](https://github.com/yarnpkg/yarn/blob/master/src/integrity-checker.js#L364-L367), so install failed. The solution was to add top level raw patterns to resolutions map, and only remove them if they're transitive patterns **Test plan** Added a new test case in resolutions *BEFORE* <img width="618" alt="screen shot 2017-10-28 at 11 07 52 am" src="https://user-images.githubusercontent.com/18429494/32137218-621a19b8-bbd0-11e7-87a3-4acd43a44a69.png"> *AFTER* <img width="538" alt="screen shot 2017-10-28 at 11 10 13 am" src="https://user-images.githubusercontent.com/18429494/32137229-9b828f1e-bbd0-11e7-90a2-1464c28fcab4.png">
…solution (yarnpkg#4793) **Summary** Fixes yarnpkg#4778. In this particular issue, the same pattern `babel-runtime@^6.26.0` was [defined in both devDependencies](https://github.com/kompot/yarn-frozen-lockfile-bug/blob/master/package.json#L80) and [resolutions field](https://github.com/kompot/yarn-frozen-lockfile-bug/blob/master/package.json#L130). Since resolutions feature was only intended for nested dependencies, it previously didn't take into account when the same exact pattern existed as a top level dependency. And it happens so that after the package resolver phase, [integrity checker looks at top level patterns](https://github.com/yarnpkg/yarn/blob/master/src/integrity-checker.js#L364-L367), so install failed. The solution was to add top level raw patterns to resolutions map, and only remove them if they're transitive patterns **Test plan** Added a new test case in resolutions *BEFORE* <img width="618" alt="screen shot 2017-10-28 at 11 07 52 am" src="https://user-images.githubusercontent.com/18429494/32137218-621a19b8-bbd0-11e7-87a3-4acd43a44a69.png"> *AFTER* <img width="538" alt="screen shot 2017-10-28 at 11 10 13 am" src="https://user-images.githubusercontent.com/18429494/32137229-9b828f1e-bbd0-11e7-90a2-1464c28fcab4.png">
Just an FYI for anyone else that hits this problem. For us it was because we had the same package listed in devDependencies and resolutions in the root package.json with different version numbers (forgot to update the devDependency). I didn't find this out until I ran through the yarn source code and put a console.log in this section:
That then clued us in to where to look. Maybe we should improve the frozen lockfile error message to include why it failed? |
@BruceHubbard Omg thanks for this |
@gaearon Sure thing, glad it helped someone. |
I know this has been closed for a long time, but just wanted to +1 @BruceHubbard for the explanation of why this behaviours happens - just happened to me with 1.22.4. It was because in the package.json file there was a resolution on a different version of the one defined in dependencies and yarn can't seem to surface that error correctly but instead only kind of "interctly notices it" when doing a frozen install. |
ditto on thanking @BruceHubbard |
FYI, "optionalDependencies" in package.json triggered this issue for me. Removing them from package.json fixed the problem. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
yarn install
with package.json present and noyarn.lock
present.yarn install --frozen-lockfile
error Your lockfile needs to be updated, but yarn was run with --frozen-lockfile.
yarn install
again - no changes are made toyarn.lock
If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/kompot/yarn-frozen-lockfile-bug
What is the expected behavior?
yarn install
should fixyarn.lock
so that it's up-to-date ORyarn --frozen-lockfile
should not failPlease mention your node.js, yarn and operating system version.
macOS 10.12.6
yarn 1.2.1
node 6.11
The text was updated successfully, but these errors were encountered: