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

When running bundle lock --update <name>, checkout locked revision of unrelated git sources directly #6459

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Mar 9, 2023

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

Since Bundler 2.4, we will try to checkout any branch specified in the Gemfile, even if there's a locked revision in the Gemfile.lock and the lockfile source has not been expired (for example, when running bundle lock --update <unrelated-gem-from-a-gem-source>). Until Bundler 2.3 we would directly checkout the locked revision in this situation.

This should not make any difference in most situations, but in some edge cases, like if the branch specified in the Gemfile has been renamed, but the locked revision still exist, it causes an error now while before it would update the lockfile without issues.

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

I debated which behavior was best, since I was not sure. But my conclusion is that if the situation does not require expiring the lockfile source in favor of the Gemfile source, we should use the locked revision directly and proceed happily. So I restored Bundler 2.3 behavior.

I think this is consistent with how yanked gems are handled, for example.

Of course, if explicitly updating the git source itself, or all gems, we will still get any errors like missing branches related to the git source.

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez changed the title When running bundle lock --update <name>, don't unlock git sources unrelated to <name> When running bundle lock --update <name>, checkout locked revision of unrelated git sources directly Mar 9, 2023
…of unrelated git sources directly

Since Bundler 2.4, we will try to checkout any branch specified in the
Gemfile, while until Bundler 2.3 we would directly checkout the locked
revision.

This should not make any difference in most situations, but in some edge
cases, like if the branch specified in the `Gemfile` has been renamed,
but the locked revision still exist, it causes an error now while before
it would update the lockfile without issues.

I debated which behavior was best, since I was not sure. But my
conclusion is that if the situation does not require expiring the
lockfile source in favor of the Gemfile source, we should use the locked
revision directly and proceed happily. So I restored Bundler 2.3
behavior.

I think this is consistent with how yanked gems are handled, for example.

Of course, if explicitly updating the git source itself, or all gems, we
will still get any errors like missing branches related to the git source.
@deivid-rodriguez deivid-rodriguez force-pushed the respect-lockfile-git-sources-when-unlocking-other-gems branch from 7aa04da to c7cc74f Compare March 10, 2023 19:15
@deivid-rodriguez deivid-rodriguez added this pull request to the merge queue Mar 13, 2023
Merged via the queue into master with commit ac7c317 Mar 13, 2023
@deivid-rodriguez deivid-rodriguez deleted the respect-lockfile-git-sources-when-unlocking-other-gems branch March 13, 2023 13:34
deivid-rodriguez added a commit that referenced this pull request Mar 20, 2023
…hen-unlocking-other-gems

When running `bundle lock --update <name>`, checkout locked revision of unrelated git sources directly

(cherry picked from commit ac7c317)
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

1 participant