`bundle lock --add-checksums` writes blank `CHECKSUMS` entries on the first run when a source's gems are only in optional or excluded groups
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- ruby
- Ambito
- build-system
Direzione di ricerca
Start with Definition#add_checksums, LockfileGenerator#add_checksums, and the specs.each materialization path described in the report. Trace how optional and excluded groups affect checksum fetching and fallback calculation, then compare that with the specs written from definition.resolve. Done means the first bundle lock --add-checksums run writes populated checksums for every locked gem, including the reported optional and excluded group cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the problem as clearly as you can
When migrating an existing Gemfile.lock without a CHECKSUMS section via bundle lock --add-checksums, Bundler writes blank checksum lines (for example rack (3.1.12)) for any gem source whose gems are all in an unrequested optional: true group or a BUNDLE_WITHOUT-excluded group (such as a scoped source inside an optional group, or a zero-runtime-dependency gemspec project with BUNDLE_WITHOUT=development). A subsequent BUNDLE_FROZEN=true install that includes the group fails with exit code 16 (Your lockfile has an empty CHECKSUMS entry). Running bundle lock --add-checksums a second time populates the sha256=... digest.
When no re-resolution is needed, Definition#add_checksums calls specs.each (materialize(requested_dependencies)), which skips unrequested optional: true and without groups (both for triggering Source::Rubygems compact-index fetches and for computing fallback checksums from installed .gem packages on disk), whereas LockfileGenerator#add_checksums emits CHECKSUMS entries for every spec in definition.resolve. On the second run, check_lockfile sees the blank entry in CHECKSUMS, sets @locked_spec_with_empty_checksums, and forces a remote re-resolution.
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-opt-checksum && cd /tmp/repro-opt-checksum
cat > Gemfile << 'EOF'
source "https://rubygems.org"
group :opt, optional: true do
gem "rack", "3.1.12"
end
EOF
BUNDLE_LOCKFILE_CHECKSUMS=false bundle lock
bundle lock --add-checksums
cat Gemfile.lock
BUNDLE_FROZEN=true BUNDLE_WITH=opt BUNDLE_PATH=vendor/bundle bundle install
bundle lock --add-checksums
cat Gemfile.lock
Which command did you run?
bundle lock --add-checksums
What were you expecting to happen?
The first bundle lock --add-checksums run should populate sha256=... checksums for all locked gems in Gemfile.lock (https://bundler.io/man/bundle-lock.1.html), matching the second run, so BUNDLE_FROZEN=true BUNDLE_WITH=opt bundle install succeeds.
What happened instead?
$ BUNDLE_LOCKFILE_CHECKSUMS=false bundle lock
Writing lockfile to /tmp/repro-opt-checksum/Gemfile.lock
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
$ bundle lock --add-checksums
Writing lockfile to /tmp/repro-opt-checksum/Gemfile.lock
$ cat Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
rack (3.1.12)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
rack (= 3.1.12)
CHECKSUMS
rack (3.1.12)
BUNDLED WITH
4.1.0
$ BUNDLE_FROZEN=true BUNDLE_WITH=opt BUNDLE_PATH=vendor/bundle bundle install
Your lockfile has an empty CHECKSUMS entry for "rack", but can't be updated
because frozen mode is set
Run `bundle install` elsewhere and add the updated Gemfile.lock to version
control.
$ bundle lock --add-checksums
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Writing lockfile to /tmp/repro-opt-checksum/Gemfile.lock
$ cat Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
rack (3.1.12)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
rack (= 3.1.12)
CHECKSUMS
rack (3.1.12) sha256=00d83055c89273eb13679ab562767b8826955aa6c4371d7d161deb975c50c540
BUNDLED WITH
4.1.0
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 /tmp/repro-opt-home/.local/share/gem/ruby/4.0.0:/opt/ruby-4.0.9/lib/ruby/gems/4.0.0
User Home /tmp/repro-opt-home
User Path /tmp/repro-opt-home/.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
```
## Gemfile
### Gemfile
```ruby
source "https://rubygems.org"
group :opt, optional: true do
gem "rack", "3.1.12"
end
```
### Gemfile.lock
```
GEM
remote: https://rubygems.org/
specs:
rack (3.1.12)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
rack (= 3.1.12)
CHECKSUMS
rack (3.1.12)
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
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ruby/rubygems
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ruby/rubygems
Issue simili
-
needs verification
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 13 giorni
-
🐛 bug 👩💻 équipe CE 🧑🏭 entreprises
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
betagouv/conseillers-entreprises#4808 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
yosiat/panko_serializer#250 ·