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

未关闭
#10,080 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ruby
领域
backend, databases

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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/

主要语言
Ruby
星标
4k
派生
2k
平均合并
1 天 20 小时
30 天内合并 PR
75

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/rubygems 的其他 Issue

查看 ruby/rubygems 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。