`bundle lock --update` and `bundle update --all` fail with `GemNotFound` when a locked top-level gem version was yanked and only older versions remain

Aperta
#10,079 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
ruby
Ambito
backend, devtools

Direzione di ricerca

Start with Definition#resolution_base, additional_base_requirements_to_prevent_downgrades, and Resolver#setup_solver in the Bundler resolver code. Trace how base_requirements filters candidates before find_names_to_relax and @base.unlock_names run. Reproduce with the supplied yanked-gem steps; done when bundle lock --update and bundle update --all resolve aa (1.0.0) as the named update commands do.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the problem as clearly as you can

When a top-level gem in Gemfile is locked to 2.0.0 and 2.0.0 is later yanked from the gem source while 1.0.0 remains available, both bundle lock --update and bundle update --all fail with exit code 7 (Bundler::GemNotFound) and print a contradictory error claiming no gem matching aa was found while listing aa-1.0.0 in the source. Naming the gem explicitly (bundle update aa or bundle lock --update aa) or locking without a prior Gemfile.lock succeeds and resolves aa (1.0.0).

In Definition#resolution_base, additional_base_requirements_to_prevent_downgrades sets base_requirements["aa"] to >= 2.0.0. During Resolver#setup_solver, prepare_dependencies checks versions_for(dep_package, dep_range) (which filters candidates through base_requirements["aa"]), relaxes ignores_prereleases? and prefer_local? when empty, but does not relax base_requirements["aa"], so it calls raise_not_found! before solve_versions can run find_names_to_relax and @base.unlock_names.

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 repro-yank-update && cd repro-yank-update
mkdir -p repo/gems repo/quick/Marshal.4.8 app

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

specs = ["1.0.0", "2.0.0"].map do |v|
  Gem::Specification.new do |s|
    s.name = "aa"
    s.version = v
    s.summary = "aa"
    s.authors = ["test"]
  end
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
File.binwrite("repo/specs.4.8.gz",
  Zlib.gzip(Marshal.dump(specs.map { |s| [s.name, s.version, "ruby"] })))
File.binwrite("repo/prerelease_specs.4.8.gz", Zlib.gzip(Marshal.dump([])))
RUBY

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

(cd app && BUNDLE_PATH=vendor/bundle bundle lock)

# Yank 2.0.0 from the source, leaving 1.0.0 available
ruby - << 'RUBY'
require "zlib"
require "fileutils"

FileUtils.rm_f(["repo/gems/aa-2.0.0.gem", "repo/quick/Marshal.4.8/aa-2.0.0.gemspec.rz"])
File.binwrite("repo/specs.4.8.gz",
  Zlib.gzip(Marshal.dump([["aa", Gem::Version.new("1.0.0"), "ruby"]])))
RUBY

cd app
BUNDLE_PATH=vendor/bundle bundle lock --update
BUNDLE_PATH=vendor/bundle bundle update --all
BUNDLE_PATH=vendor/bundle bundle update aa
Which command did you run?

bundle lock --update and bundle update --all

What were you expecting to happen?

Both bundle lock --update and bundle update --all should resolve all dependencies against the versions currently available in the source (https://bundler.io/man/bundle-update.1.html) and update Gemfile.lock to aa (1.0.0), matching bundle update aa and bundle lock --update aa.

What happened instead?
$ BUNDLE_PATH=vendor/bundle bundle lock --update
Writing lockfile to /tmp/repro-yank-update/app/Gemfile.lock
Fetching source index from file:///tmp/repro-yank-update/repo/
Could not find gems matching 'aa' valid for all resolution platforms (ruby,
x86_64-linux) in rubygems repository
file:///tmp/repro-yank-update/repo/
or installed locally.

The source contains the following gems matching 'aa':
  * aa-1.0.0

$ BUNDLE_PATH=vendor/bundle bundle update --all
Fetching source index from file:///tmp/repro-yank-update/repo/
Could not find gems matching 'aa' valid for all resolution platforms (ruby,
x86_64-linux) in rubygems repository
file:///tmp/repro-yank-update/repo/
or installed locally.

The source contains the following gems matching 'aa':
  * aa-1.0.0

$ BUNDLE_PATH=vendor/bundle bundle update aa
Fetching source index from file:///tmp/repro-yank-update/repo/
Resolving dependencies...
Resolving dependencies...
Fetching aa 1.0.0 (was 2.0.0)
Installing aa 1.0.0 (was 2.0.0)
Note: aa version regressed from 2.0.0 to 1.0.0
Bundle updated!
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: "/tmp/repro-yank-update/app/vendor/bundle"
```

## Gemfile

### Gemfile

```ruby
source "file:///tmp/repro-yank-update/repo"
gem "aa"
```

### Gemfile.lock

```
GEM
  remote: file:///tmp/repro-yank-update/repo/
  specs:
    aa (2.0.0)

PLATFORMS
  ruby
  x86_64-linux

DEPENDENCIES
  aa

CHECKSUMS
  aa (2.0.0)

BUNDLED WITH
  4.1.0
```

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

Lingua principale
Ruby
Stelle
4k
Fork
2k
Merge medio
1g 20h
PR unite (30g)
75

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ruby/rubygems

Tutte le issue di ruby/rubygems

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.