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

Fix unintentional downgrades when gemspec DSL is used #6131

Merged
merged 1 commit into from
Dec 16, 2022

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Dec 14, 2022

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

Bundler sets >= <locked_version> additional resolution requirements for all direct dependencies, in order to avoid downgrades.

Those are passed on to the resolver through this array here:

def additional_base_requirements_for_resolve(last_resolve)
return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
converge_specs(@originally_locked_specs - last_resolve).map do |locked_spec|
Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
end.uniq
end

In this case thought, an empty array is being passed (so no additional lower bound requirements due to sources.expired_sources?(@locked_gems.sources) being true.

That accounts for the case when the user changes Gemfile sources, expiring those in the lock file. In that case, it's possible that a gem in the new source needs to be downgraded, so lower bound requirements are not passed.

Here, however, nobody is changing any sources, and that method is still returning true. That's the bug. Closer inspection reveals that the Source::Path source included in Gemfile.lock is being considered different to the Source::Gemspec source included in the Gemfile. They are actually the same thing though.

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

This commit fixes the issue by properly normalizing Gemspec and Path sources so that they can be properly compared.

Fixes #6129.

Make sure the following tasks are checked

Bundler sets `>= <locked_version>` additional resolution requirements
for all direct dependencies, in order to avoid downgrades.

However, there's some exceptions to this related to changing Gemfile
sources. This exception was being unintentionally hit because of path
Gemfile.lock sources and gemspec Gemfile sources being treated as
different even if they are the same.

This commit fixes the issue by properly normalizing these.
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.

Bundler 2.4.0.dev causes Rake to get downgraded on rails/rails
1 participant