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 sure bundle update <specific_gems> can always update to the latest resolvable version of each requested gem #7558

Merged
merged 3 commits into from Apr 29, 2024

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Apr 4, 2024

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

Sometimes bundle update foo won't actually update foo, even if a clean bundle install will resolve to a higher version of foo than the one currently locked.

The problem is that other locked dependencies may be setting some constraints on dependencies of foo, preventing it from being upgraded. These locked dependencies are not present on a clean bundle install.

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

My fix is, if bundle update foo is requested, and initial try did not update foo, try unlocking other gems, even if they are not dependencies of foo. Keep doing this until foo updates, or it's not possible to unlock more gems.

Fixes #3310.
Fixes #5463.
Fixes #7176.

Supersedes #5520.

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez force-pushed the update-until-really-updates branch 3 times, most recently from 077d688 to c0a65f5 Compare April 26, 2024 16:17
@deivid-rodriguez deivid-rodriguez changed the title Try unlocking more gems if explicitly requested updates didn't actually get updated Make sure bundle update <specific_gems> can always update to the latest resolvable version of each requested gem Apr 26, 2024
@deivid-rodriguez
Copy link
Member Author

It took me a while to figure this out, but I think I found the best approach to tackle this 🎉.

I realized that the initial approach here was too naive and could result in unnecessary updates unrelated to updating the requested gems. I had also only implemented the solution for bundle update <specific_gem>, but not for multiple gems.

I figured out a better algorithm which is the following. When bundle update <specific_gems> is run, first do a full bundle update and parse the resulting versions of the specifically requested gems. Then add additional constraints to the resolver to force those versions. Adding these constraints may result into conflicts, however, our resolver already has logic to resolve conflicts by incrementally unlocking conflicting gems as necessary, so this just works I think!

As a nice extra, this approach should make it easier to implement further improvements, like #3290.

Since resolution options don't change.
To make sure we can always update to the latest resolvable version for
each gem explicitly requested for update, we first run a full update,
and then add explicit exact requirements to the resolved versions. This
may lead into conflicts, but our resolver already automatically parses
those and unlocks additional gems to fix them.
@deivid-rodriguez deivid-rodriguez merged commit d95430f into master Apr 29, 2024
83 checks passed
@deivid-rodriguez deivid-rodriguez deleted the update-until-really-updates branch April 29, 2024 10:29
deivid-rodriguez added a commit that referenced this pull request Apr 30, 2024
Make sure `bundle update <specific_gems>` can always update to the latest resolvable version of each requested gem

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