Skip to content

Allow selective version resolutions for transitive dependencies #8021

@hlascelles

Description

@hlascelles

The problem

Sometimes we are aware that a transitive dependency has a CVE. A bundle update somegem will update that gem in the lockfile temporarily, but it may slip back down later. We want to specify a version for it to ensure it stays above a minimum, but without implying that it is directly depended on by the root project.

This would be the equivalent of the resolutions section in yarn. To the best of my searching ability, I don't think bundler has this functionality.

Proposal

Introduce a resolutions section (like a group) to specify these needed resolutions which are not direct dependencies.

eg:

# Proposed syntax:
resolutions do
  gem "thingparser", "> 0.1.0" # Has CVE!
end

Steps to reproduce the problem

Consider:

### Gemfile
source "https://rubygems.org"

gem "somegem", "~> 1.0.0"  # Has a transitive dependency on 'thingparser'

### Lockfile
GEM
  remote: https://rubygems.org/
  specs:
    somegem (1.0.0)
      thingparser (~> 0.1.0)
    thingparser (0.1.0)

DEPENDENCIES
  somegem (~> 1.0.0)

Now, we learn that thingparser has a CVE, and 0.1.1 is required. I would like to do:

### Gemfile
source "https://rubygems.org"

gem "somegem", "~> 1.0.0"

# Proposed syntax:
resolutions do
  gem "thingparser", "> 0.1.0"
end

### Lockfile
GEM
  remote: https://rubygems.org/
  specs:
    somegem (1.0.0)
      thingparser (~> 0.1.0)
    thingparser (0.1.1)

DEPENDENCIES
  somegem (~> 1.0.0)

Note, the thingparser gem is now specified above 0.1.0, but my intent is clear in the Gemfile that I don't directly depend on it.

We would find this valuable in bundler.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions