`bundle install` / `bundle lock` fails without considering a transitive prerelease dependency when a conflicting stable release exists

Open
#10,080 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
backend, databases

Research direction

Start with Resolver::Package#filter_prereleases and Resolver#find_names_to_relax in Bundler’s resolver, then trace how the PubGrub conflict tree records cause.incompatibility and cause.satisfier. Reproduce with the provided local gem repository and commands. Done when bundle install and bundle lock resolve aa, bb 1.0.0.rc1, and cc 1.0.0 in this case.

Written by the indexing model from the issue text.

Description

Describe the problem as clearly as you can

When a gem aa declares a prerelease dependency on bb (such as bb ~> 1.0.0.rc1) alongside cc ~> 1.0, bb 1.0.0.rc1 is compatible with cc 1.0.0, and a stable bb 1.0.0 also exists that requires cc >= 2.0, both bundle install and bundle lock fail with exit code 6 (Could not find compatible versions) without ever considering bb 1.0.0.rc1. Running gem install aa against the same repository succeeds and installs aa-1.0.0, bb-1.0.0.rc1, and cc-1.0.0.

Non-root Resolver::Package instances start with @prerelease = :ignore, so filter_prereleases strips bb 1.0.0.rc1 on the initial pass while bb 1.0.0 exists. When that pass fails, Resolver#find_names_to_relax only walks incompatibility = cause.incompatibility along the left spine of the PubGrub conflict tree instead of traversing cause.satisfier as well, so it misses bb whenever the bb conflict sits on the cause.satisfier branch and aborts instead of retrying with prereleases enabled for bb.

Did you try upgrading rubygems & bundler?

Yes. Reproduced on RubyGems / Bundler 4.1.0 (Ruby 4.0.9) and on ruby/rubygems master (5879ffe34b, 4.2.0.dev).

Post steps to reproduce the problem
mkdir /tmp/repro-trans-pre && cd /tmp/repro-trans-pre
mkdir -p repo/gems repo/quick/Marshal.4.8 app

ruby - << 'RUBY'
require "rubygems/package"
require "zlib"

specs = [
  Gem::Specification.new do |s|
    s.name = "aa"; s.version = "1.0.0"; s.summary = "aa"; s.authors = ["test"]
    s.add_dependency "bb", "~> 1.0.0.rc1"
    s.add_dependency "cc", "~> 1.0"
  end,
  Gem::Specification.new do |s|
    s.name = "bb"; s.version = "1.0.0.rc1"; s.summary = "bb rc"; s.authors = ["test"]
  end,
  Gem::Specification.new do |s|
    s.name = "bb"; s.version = "1.0.0"; s.summary = "bb rel"; s.authors = ["test"]
    s.add_dependency "cc", ">= 2.0"
  end,
  Gem::Specification.new do |s|
    s.name = "cc"; s.version = "1.0.0"; s.summary = "cc"; s.authors = ["test"]
  end,
]

specs.each do |s|
  gem_file = Gem::Package.build(s, true)
  File.rename(gem_file, "repo/gems/" + gem_file)
  File.binwrite("repo/quick/Marshal.4.8/" + s.original_name + ".gemspec.rz",
    Zlib::Deflate.deflate(Marshal.dump(s)))
end

rel, pre = specs.partition { |s| !s.version.prerelease? }
File.binwrite("repo/specs.4.8.gz",
  Zlib.gzip(Marshal.dump(rel.map { |s| [s.name, s.version, "ruby"] })))
File.binwrite("repo/prerelease_specs.4.8.gz",
  Zlib.gzip(Marshal.dump(pre.map { |s| [s.name, s.version, "ruby"] })))
RUBY

cat > app/Gemfile <<GEMFILE
source "file://$PWD/repo"
gem "aa"
GEMFILE

gem install aa -i "$PWD/gemhome" --clear-sources --source "file://$PWD/repo" --no-document
(cd app && BUNDLE_PATH=vendor/bundle bundle install)
(cd app && BUNDLE_PATH=vendor/bundle bundle lock)
Which command did you run?

bundle install and bundle lock

What were you expecting to happen?

bundle install and bundle lock should resolve aa (1.0.0), bb (1.0.0.rc1), and cc (1.0.0), matching gem install aa and the documented prerelease requirement behavior (https://guides.rubygems.org/dependency-resolution/#what-version-constraints-mean).

What happened instead?
$ gem install aa -i "$PWD/gemhome" --clear-sources --source "file://$PWD/repo" --no-document
Successfully installed bb-1.0.0.rc1
Successfully installed cc-1.0.0
Successfully installed aa-1.0.0
3 gems installed

$ (cd app && BUNDLE_PATH=vendor/bundle bundle install)
Fetching source index from file:///tmp/repro-trans-pre/repo/
Resolving dependencies...
Could not find compatible versions

Because every version of bb depends on cc >= 2.0
  and every version of aa depends on bb ~> 1.0.0.rc1,
  every version of aa requires cc >= 2.0.
So, because every version of aa depends on cc ~> 1.0
  and Gemfile depends on aa >= 0,
  version solving has failed.
If not included with the output of your command, run bundle env and paste the output below
## Environment

```
Bundler       4.1.0
  Platforms   ruby, x86_64-linux
Ruby          4.0.9p0 (2026-10-23 revision 3e93b23afcec3433f6aecc34b5d832799d754238) [x86_64-linux]
  Full Path   /opt/ruby-4.0.9/bin/ruby
  Config Dir  /opt/ruby-4.0.9/etc
RubyGems      4.1.0
  Gem Home    /opt/ruby-4.0.9/lib/ruby/gems/4.0.0
  Gem Path    /home/user/.local/share/gem/ruby/4.0.0:/opt/ruby-4.0.9/lib/ruby/gems/4.0.0
  User Home   /home/user
  User Path   /home/user/.local/share/gem/ruby/4.0.0
  Bin Dir     /opt/ruby-4.0.9/bin
Git           2.39.5
```

## Bundler Build Metadata

```
Timestamp  2026-11-16
Git SHA    9af9267
```

## Bundler settings

```
path
  Set via BUNDLE_PATH: "vendor/bundle"
```

## Gemfile

### Gemfile

```ruby
source "file:///tmp/repro-trans-pre/repo"
gem "aa"
```

### Gemfile.lock

```
<No /tmp/repro-trans-pre/app/Gemfile.lock found>
```

Credit: https://ucsbplse.github.io/

Dominant language
Ruby
Stars
4k
Forks
2k
Avg merge
1d 20h
Merged PRs (30d)
75

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/rubygems

All issues in ruby/rubygems

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.