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

Abierto
#10,080 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
ruby

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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/

Lenguaje dominante
Ruby
Estrellas
4k
Forks
2k
Merge medio
1 d 20 h
PR fusionados (30 d)
75

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ruby/rubygems

Todos los issues de ruby/rubygems

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.