Behind a private gem mirror a hosted gem pin cannot be undone: `rollback` and `remove` refuse on a `CHECKSUMS` lock, and without `CHECKSUMS` `rollback` leaves the patched builds installed with no warning that names them
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 12/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Domínio
- build-system, cli
Direção de pesquisa
The refusal is raised in crates/socket-patch-core/src/patch/redirect/upstream/gem.rs (the same_remote check against RUBYGEMS_REMOTE, around line 1410), and the stale-install warning is in crates/socket-patch-cli/src/commands/gem_refresh.rs. Read CLI_CONTRACT.md's 'The unwind is exact' and 'Gem stale-install guard' sections first, and check open PR #2233 before starting, since it is already linked. Done means rollback and remove restore the pre-scan Gemfile and Gemfile.lock on a CHECKSUMS lock with a mirror source, or the scan declines to wire the gem, and the Bundler 2.5 case names the patched files to remove.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
When a project's Gemfile names a private gem mirror as its source (source "https://gems.example.com": Artifactory, Nexus, Gemstash, a static gem generate_index server), scan --mode hosted wires the gems and replaces the installed copies with the patched builds as usual, but the pin can't be undone with socket-patch afterwards:
- Lock with
CHECKSUMS(Bundler 2.6 and later, 4.x):rollbackandremovealways refuse with "its upstream GEM remote … is not rubygems.org, so its CHECKSUMS sha256 cannot be re-derived" (exit 1). The scan that wired the gem printedsocket-patch rollback pkg:gem/<gem>@<version>as the way to move it to a newer release, so its own remedy can't be followed. The refusal's remedy,git checkout -- Gemfile Gemfile.lock, restores the pair but leaves the patched builds invendor/bundle: the app keeps loading the patched code,socket-patch rollbackthen says "No patches in this project", andbundle pristinefails on the checksum (exit 37), removes the gems, and the app no longer loads. - Lock without
CHECKSUMS(Bundler 2.5):rollbackexits 0 and restores the pair byte for byte, but leaves the patched builds installed and says only "2 unwired packages keep their patched bytes in installed trees until the next package-manager install". That is not true for Bundler:bundle installkeeps them andbundle pristinereinstalls them from the patched archive incache/. Noupstream_gem_stale_installwarning names the files to remove.
The mirror serves the very same .gem files as rubygems.org here (same sha256), so the checksum to restore is the one the lock held before the scan and the one the rubygems.org index lists.
A mirror set with bundle config mirror.https://rubygems.org is not affected (the lock still says remote: https://rubygems.org/). This is about a source line that names the mirror, which is how many companies reach gems.
Impact
A project that installed cleanly can't get back to its pre-scan state with the tool. On Bundler 2.6+ the documented way out ends in a failing bundle pristine and a broken gem home. On Bundler 2.5 rollback reports success while the app still runs the patched gems. rollback pkg:gem/<gem>@<version> of one gem out of several (to upgrade it, as the scan suggests) is impossible: git checkout of the pair drops every pin.
Repro
Uses the repo's stand-in patch service (tests/nokogiri/patch_service.rb) for rack 2.2.8 and rake 13.2.1 on a loopback port; every socket-patch call below also takes --api-url <mock> --patch-server-url <mock> --api-token fake --org nokogiri-e2e. Ruby 3.3.6.
# a private mirror holding the unmodified upstream gems
mkdir -p mirror/gems && cd mirror
(cd gems && gem fetch rack -v 2.2.8 && gem fetch rake -v 13.2.1)
gem generate_index -d . && python3 -m http.server 18091 --bind 127.0.0.1 &
cd ..
mkdir app && cd app
printf 'source "http://127.0.0.1:18091"\n\ngem "rack", "2.2.8"\ngem "rake", "13.2.1"\n' > Gemfile
bundle config set --local path vendor/bundle && bundle install # Bundler 4.0.18
cp Gemfile Gemfile.orig && cp Gemfile.lock Gemfile.lock.orig
socket-patch scan --mode hosted
# Replaced the installed copy of 2 gems with the patched build: rack 2.2.8, rake 13.2.1.
# ... To move one to a newer release, run `socket-patch rollback pkg:gem/<gem>@<version>`, ...
socket-patch rollback pkg:gem/[email protected] # exit 1
# Error: Cannot restore pkg:gem/[email protected] to its upstream registry entry: its upstream GEM remote
# http://127.0.0.1:18091/ is not rubygems.org, so its CHECKSUMS sha256 cannot be re-derived; restore it
# from version control instead (`git checkout -- Gemfile Gemfile.lock`)
socket-patch remove pkg:gem/[email protected] # same error, exit 1
SOCKET_RUBYGEMS_URL=http://127.0.0.1:18091 socket-patch rollback # same error
# the remedy the refusal names
cp Gemfile.orig Gemfile && cp Gemfile.lock.orig Gemfile.lock
bundle install # "Bundle complete!"; the app still loads the patched rack and rake
socket-patch rollback # Error: No patches in this project; nothing to roll back.
bundle pristine # exit 37: "Bundler found mismatched checksums", gems removed
bundle exec ruby -e 'require "rack"' # LoadError
With Bundler 2.5.22 (no CHECKSUMS section) on the same project:
socket-patch scan --mode hosted
socket-patch rollback # exit 0, Gemfile and Gemfile.lock byte-identical to the originals
# Note: 2 unwired packages keep their patched bytes in installed trees until the next package-manager install.
bundle install && bundle pristine
bundle exec ruby app.rb # still the patched rack and rake
rollback --json there has status: success and one warning, reinstall_required; no upstream_gem_stale_install.
Expected
CLI_CONTRACT.md("The unwind is exact"):rollback/removegive back the pre-scan pair byte for byte. The task of this routine states the same bar. If hosted mode can't undo a pin for a lock it is about to edit, the scan should either not wire the gem (warn and name--mode agent), or be able to restore it: the pre-scan sha256 is in the lock the scan rewrites, the upstream archive is in the gem home'scache/before the scan replaces it, and the mirror serves a compact index (info/<name>) with the checksum.- The hold note should not offer
socket-patch rollback pkg:gem/<gem>@<version>where it will refuse. CLI_CONTRACT.md("Gem stale-install guard", the unwind direction): "a gem from another remote is refreshed only from an archive already on disk" and "what is still the patched build is warned about once (upstream_gem_stale_install)", naming the files to remove beforebundle install. On the Bundler 2.5 lock no such warning is printed, only the generic note, whose "next package-manager install" does not replace anything under Bundler.
Actual
See the summary. On a CHECKSUMS lock the pin is one-way; without CHECKSUMS the pair is restored and the patched installs stay, unreported.
Versions
| Result | |
|---|---|
main e685fb1 (5.1.0 + 33 commits), Bundler 4.0.18, Ruby 3.3.6, mirror as the only top-level source |
reproduces: rollback and remove refuse; git checkout remedy leaves patched installs, bundle pristine exits 37 |
main e685fb1, Bundler 2.5.22, Ruby 3.3.6, same project |
reproduces the second form: pair restored, patched builds stay, no upstream_gem_stale_install |
main e685fb1, Bundler 4.0.18, source "https://rubygems.org" |
does not reproduce: "Replaced the installed copy of 1 gem with the upstream build", pair byte-exact |
Linux only. Nothing here looks platform-specific. First bad release not searched; the refusal text predates 5.1.0.
Suspect code
crates/socket-patch-core/src/patch/redirect/upstream/gem.rs:1410(thesame_remote(&remote, RUBYGEMS_REMOTE)refusal; nothing on the scan side checks it before wiring).crates/socket-patch-cli/src/commands/rollback.rs:2803(the generic note) andcrates/socket-patch-cli/src/commands/gem_refresh.rs:58(upstream_gem_stale_install, not raised for a gem from another remote with no upstream archive on disk).
Generated by Claude Code
- Linguagem predominante
- Rust
- Estrelas
- 9
- Forks
- 2
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 309
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de SocketDev/socket-patch
-
Windows unit tests fail on main: pnpm-registry-overrides fixtures are checked out as CRLF (mixes CRLF and LF line endings)Talvez já em andamento @mikolalysenko assumiu hoje. Abertaagent:claimed agent:triaged ci-janitor priority:p1
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 85/100
SocketDev/socket-patch#2238 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
SocketDev/socket-patch#1860 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
SocketDev/socket-patch#1838 ·
Mantenedores costumam responder em até 1 dia
-
Nightly: pnpm11_registry_route_is_cleaned_up_when_a_patch_is_not_needed fails on Windows (pnpm records the RUNNER~1 short path as a second importer)Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertaagent:triaged ci-janitor priority:p1
Dificuldade 3/5 Meio dia Facilidade para iniciantes 42/100
SocketDev/socket-patch#2235 ·
Mantenedores costumam responder em até 1 dia
-
Agent mode reports a gem whose installed file was edited as "not installed on this host" / "not found on disk", `apply --check` says to run `apply`, and `rollback` exits 1 with "modified after patching" on every runTalvez já em andamento @mikolalysenko assumiu hoje. Abertaagent:claimed agent:triaged bug bughunt pm:bundler priority:p1 ux
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 18/100
SocketDev/socket-patch#2231 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-patch
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
qingjian-team/qingjian#1181 ·
Mantenedores costumam responder em até 2 dias
-
bug P2: medium
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
leepokai/Codync#618 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
oxidecomputer/opte#1125 ·
Mantenedores costumam responder em até 2 dias
-
[Bug] StreamLifecycleConfig clamps post-TTFT stream timeouts to remaining admission budgetTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
lbjlaq/Antigravity-Manager#4063 ·
Mantenedores costumam responder em até 1 dia