-
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 is not failing as expected #5840
yarn install --frozen-lockfile is not failing as expected #5840
Comments
Closing this ticket as it was due to modifications in config files related to repos and not yarn |
Actually I need someone else to validate this as the issue is persisting despite us trying to fix things on our end. |
Turns out there were some things wrong on our end but there is still an issue with yarn install --frozen-lockfile - I've edited the title and the original post to reflect that.
I realize in the reproduce steps I said to use |
@DavideDaniel I'm seeing the same issue with @torifat Have you had an opportunity to look into this? |
@arcanis Is there any movement on this? There hasn't been any response from the assignee or anyone else within the Yarn org. |
I don't understand. What makes you think it should fail? If you remove dependencies from your package.json, your lockfiles might now contain extraneous useless entries that could be optimized away, but it'll still install things in a repeatable way without having to be modified (so no error needed). Does that make sense? |
It should fail because the docs says it will. It is what separates it from We need this functionality to catch cases on our ci where a developer updates a dependency without updating the lockfile. Otherwise every other developer that pulls down the commit ends up with a modified |
@arcanis It looks like |
No, pure-lockfile simply doesn't write the changes.
I can see why you'd think frozen-lockfile should throw on this occasion tho. If you're willing to open a PR, I can review it. |
@arcanis So Nonetheless, the problem demonstrated by the repo @devrelm created doesn't meet that description. In that repo, a workspace dependency is updated to require a different version than is present in the lockfile. That means that an update to the lockfile is strictly required, yet I've experienced the same problem, and I also suspect that it's only broken for workspaces. Even adding an entirely new dependency in a workspace doesn't seem to make Perhaps we should create a separate ticket, as it does appear that it might be a different problem than described in the OP. |
I've created a failing test here: https://github.com/Gudahtt/yarn/tree/workspace-frozen-lockfile |
I just ran into this (package removed from I totally understand that some optimizations (eg general |
I have created #6291 for the workspace-specific problem discussed here. @DavideDaniel can you reproduce this problem in a project that isn't using workspaces? If not, perhaps this ticket can be closed. |
Mine occurred when not using a workspace. |
@edmorley Ah, right. I think there are two distinct issues here, and yours is the other one. Sorry for the confusion. The first issue is the situation described by you , where The second issue is when updates are absolutely required, but It looks like the OP was in the same situation as you, where the command was behaving as designed but in confusing manner not well explained by the documentation. But I'm not completely certain of that. I wanted to know from the OP whether they only encountered this problem when removing packages (just as you), or whether they encountered it when adding packages as well (but just chose to use removal as an example in the issue description). |
Our current workaround in a Linux-based CI environment: yarn install
git diff yarn.lock
if ! git diff --exit-code yarn.lock; then
echo "Changes were detected in yarn.lock file after running 'yarn install', which is not expected. Please run 'yarn install' locally and commit the changes.";
exit 1;
fi The problem remained unnoticed for months 😅 |
We have a similar workaround to @kachkaev
|
This should ensure that we don't run into the kind of issue mentioned here: #233 (comment) Note that `--frozen-lockfile` is supposed to take care of this for us, but it is a known issue that it doesn't work properly in monorepos: yarnpkg/yarn#5840 There is a fix for it: yarnpkg/yarn#6554 But the issue is nearly two years old and the PR is almost as old. Maintainer replies here: yarnpkg/yarn#6554 (comment) that: > The change appears sound, but we're currently working on the v2 > (scheduled before the end of the year) and I'm somewhat worried about > introducing subtle bugs right before releasing the next major (the > way I see it, the current v1 is, despite its shortcomings, relatively > stable)." We face a similar concern in liferay-portal and have a ticket for that: https://issues.liferay.com/browse/LPS-110313
This should ensure that we don't run into the kind of issue mentioned here: #233 (comment) Note that `--frozen-lockfile` is supposed to take care of this for us, but it is a known issue that it doesn't work properly in monorepos: yarnpkg/yarn#5840 There is a fix for it: yarnpkg/yarn#6554 But the issue is nearly two years old and the PR is almost as old. Maintainer replies here: yarnpkg/yarn#6554 (comment) that: > The change appears sound, but we're currently working on the v2 > (scheduled before the end of the year) and I'm somewhat worried about > introducing subtle bugs right before releasing the next major (the > way I see it, the current v1 is, despite its shortcomings, relatively > stable)." We face a similar concern in liferay-portal and have a ticket for that: https://issues.liferay.com/browse/LPS-110313
Fixed in the v2. |
@paul-soporan Just for clarity - was this ever fixed for Classic Yarn (1.x)? Facing this issue in 1.22.5 and I'd rather not have to migrate to v2. 🙃 |
1.x is frozen and will only receive security fixes, so the answer is no. |
that's bad, we can't migrate to v2. at least not in the near year. we'll probably go with pnpm. if there's an open PR for something that is hanging for a long time, why not merge it? |
@AlonMiz v1 is frozen, and they've moved most of their developer resources to v2 instead. Merging this PR would mean merging any open PR that is approved or close to it, which ruins the entire point of freezing this version. It's definitely annoying, though 😕 I might be wrong but I do think there are forks of Yarn v1 that have merged this fix-in, you can see that above by looking at repos where this issue was mentioned. This isn't a great solution since using unofficial spin-offs of Yarn can carry massive security issues, but still. |
Seems like `yarn install --frozen-lockfile` doesn't always fail when `yarn.lock` changes (we put there the option believing it does). See: yarnpkg/yarn#5840 Instead, we should simply try to install the dependencies as usual and fail if something in the repo changes unexpectedly. Inspiration: facebook/docusaurus@4d93c89
Seems like `yarn install --frozen-lockfile` doesn't always fail when `yarn.lock` changes (we put there the option believing it does). See: yarnpkg/yarn#5840 Instead, we should simply try to install the dependencies as usual and fail if something in the repo changes unexpectedly. Inspiration: facebook/docusaurus@4d93c89
Seems like `yarn install --frozen-lockfile` doesn't always fail when `yarn.lock` changes (we put there the option believing it does). See: yarnpkg/yarn#5840 Instead, we should simply try to install the dependencies as usual and fail if something in the repo changes unexpectedly. Inspiration: facebook/docusaurus@4d93c89
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
yarn install --frozen-lockfile
does not generate a new yarn.lock but it does NOT fail as expected.If the current behavior is a bug, please provide the steps to reproduce.
yarn install --frozen-lockfile
proceeds with install instead of failing as docs say, and does not generate a new yarn.lock to reflect the change in package.json.What is the expected behavior?
Per docs:
Don’t generate a yarn.lock lockfile and fail if an update is needed.
It should fail as expected as CI builds need to break earlier rather than wait for build and then fail on a missing or mismatched dependency.
Please mention your node.js, yarn and operating system version.
Node 8.9.1 | 9.6.1
npm 3.10.10 | 5.6.0
MacOS 10.12.6
The text was updated successfully, but these errors were encountered: