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

Make the lock command not be affected by the frozen setting #7034

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

deivid-rodriguez
Copy link
Member

What was the end-user or developer problem that led to this PR?

The lock command is specifically designed to manage the lockfile, so running it should take precedence over any "frozen" setting.

Besides that, "frozen" is not specifically designed as "lockfile cannot be updated" but as "installation of gems should be prevented if gemfile is not in sync with the lockfile".

The lock command does not install any gems and preserves the property of the lockfile being in sycn with its gemfile, so I think frozen should not influence it.

The current behavior is quite confusing when frozen is set. On an app where rubocop can get lockfile updates

```
$ bundle lock --update rubocop
Writing lockfile to /path/to/Gemfile.lock
```

Completely silent, it makes you think that it has written the lockfile, but still no updates.

In verbose mode, it gives a bit more information, but still confusing and unexpected, and does not change the lockfile:

```
$ bundle lock --update rubocop --verbose
Running `bundle lock --update "rubocop" --verbose` with bundler 2.4.20
Frozen, using resolution from the lockfile
Writing lockfile to /path/to/Gemfile.lock
```

What is your fix for the problem, implemented in this PR?

With this commit, it updates the lockfile as expected, by ignoring the frozen setting during bundle lock.

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez changed the title Make the lock not be affected by the frozen setting Make the lock command not be affected by the frozen setting Oct 4, 2023
Copy link
Member

@indirect indirect left a comment

Choose a reason for hiding this comment

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

This is great, thank you!

@deivid-rodriguez
Copy link
Member Author

Thanks @indirect!

I included a refactoring that I don't think it's strictly related to this improvement, and while I think it's pretty nice, it does change the signature of a public method in Bundler::Definition, so I fear it might break some usage. In particular, I'd like to check if it could affect https://github.com/Shopify/bootboot.

So, I think I'm going to remove that change from this PR and consider it separately (whether it's fine, needs a deprecation or whatever).

Not that I consider this particular Bundler::Definition#lock method as public, but I also don't want to break people's code.

@martinemde
Copy link
Member

martinemde commented Oct 7, 2023

@deivid-rodriguez I like the refactor and understand not wanting to break things. I think a deprecation warning makes sense given the code in bootboot. However, I think this refactor will be appreciated. It may even help the problem they're solving by patching Definition.new (but I didn't dig any further to see why or how that's used).

@deivid-rodriguez
Copy link
Member Author

deivid-rodriguez commented Oct 9, 2023

@martinemde I fully agree with everything you said. I suspect this refactoring would allow bootboot to remove some Bundler monkey patches which would be good for everyone.

I'll move the refactoring away from this PR and propose it separately in a smoother way (with deprecation).

The `lock` command is specifically designed to manage the lockfile, so
running it should take precedence over any "frozen" setting.

Besides that, "frozen" is not specifically designed as "lockfile cannot
be updated" but as "installation of gems should be prevented if gemfile
is not in sync with the lockfile".

The lock command does not install any gems and preserves the property of
the lockfile being in sycn with its gemfile, so I think frozen should
not influence it.

The current behavior is quite confusing when frozen is set. On an app
where rubocop can get lockfile updates

```
$ bundle lock --update rubocop
Writing lockfile to /path/to/Gemfile.lock
```

Completely silent, it makes you think that it has written the lockfile,
but still no updates.

In verbose mode, it gives a bit more information, but still confusing
and unexpected, and does not change the lockfile:

```
$ bundle lock --update rubocop --verbose
Running `bundle lock --update "rubocop" --verbose` with bundler 2.4.20
Frozen, using resolution from the lockfile
Writing lockfile to /path/to/Gemfile.lock
```

With this commit, it updates the lockfile as expected.
@deivid-rodriguez deivid-rodriguez merged commit 28f813b into master Oct 9, 2023
92 checks passed
@deivid-rodriguez deivid-rodriguez deleted the fix-lock-with-frozen branch October 9, 2023 12:16
deivid-rodriguez added a commit that referenced this pull request Oct 13, 2023
Make the `lock` command not be affected by the `frozen` setting

(cherry picked from commit 28f813b)
deivid-rodriguez added a commit that referenced this pull request Oct 13, 2023
Make the `lock` command not be affected by the `frozen` setting

(cherry picked from commit 28f813b)
deivid-rodriguez added a commit that referenced this pull request Oct 13, 2023
Make the `lock` command not be affected by the `frozen` setting

(cherry picked from commit 28f813b)
deivid-rodriguez added a commit that referenced this pull request Oct 16, 2023
Make the `lock` command not be affected by the `frozen` setting

(cherry picked from commit 28f813b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants