Repository navigation
Description
[agent] Found by the scheduled pip / requirements.txt bug-hunt routine (ledger #309).
Summary
When a project keeps its hashes in a -c constraints file (for example pip-compile --generate-hashes -o constraints.txt) and its root requirements.txt lists the packages unhashed, scan --mode vendored writes the vendor lines without --hash. Since pip 26.1, that layout installs: hashes in a constraints file satisfy hash-checking mode. After vendoring, the next pip install -r requirements.txt fails with "Hashes are required in --require-hashes mode, but they are missing from some requirements". The scan, vendor --check and vex all report success.
The cause: when vendored mode decides whether the tree is in hash-checking mode, it reads only the root file and its -r includes. It never reads the -c files, but pip turns hash-checking mode on for a hash in a constraints file too.
Impact
This breaks the "do no harm" rule. A project that installed cleanly with pip ≥ 26.1 can no longer install after scan --mode vendored, and CI fails on its next pip install -r requirements.txt. Nothing in the run warns about it: the scan exits 0, and vendor --check reports "committed artifact and wiring verified".
Repro (Linux, pip 26.3 / CPython 3.12, local mock of the patch API serving free patches for idna 3.7 and six 1.16.0)
git init p && cd p
printf 'idna==3.7\nsix==1.16.0\n' > requirements.in
pip-compile --generate-hashes -o constraints.txt requirements.in # hashed pins
printf -- '-c constraints.txt\nidna==3.7\nsix==1.16.0\n' > requirements.txt
git add -A && git commit -qm init
python3.12 -m venv v0 && v0/bin/pip install -q pip==26.3
v0/bin/pip install -r requirements.txt # exit 0 (baseline installs)
socket-patch scan --mode vendored # "Vendored 2 packages.", exit 0
cat requirements.txt
# -c constraints.txt
# ./.socket/vendor/pypi/<uuid>/idna-3.7-py3-none-any.whl # socket-patch vendor: idna==3.7
# ./.socket/vendor/pypi/<uuid>/six-1.16.0-py2.py3-none-any.whl # socket-patch vendor: six==1.16.0
socket-patch vendor --check # both "committed artifact and wiring verified", exit 0
python3.12 -m venv v1 && v1/bin/pip install -q pip==26.3
v1/bin/pip install -r requirements.txt
# ERROR: Hashes are required in --require-hashes mode, but they are missing from some requirements. ...
# file:///…/.socket/vendor/pypi/<uuid>/idna-3.7-py3-none-any.whl --hash=sha256:589c20c6…
# exit 1It also reproduces with a single package and a hand-written constraints.txt (six==1.16.0 --hash=sha256:<PyPI wheel hash>).
If the vendor line carries --hash=sha256:<vendored wheel sha256>, which is what vendored mode already writes when the requirements tree itself has a hash, the same install succeeds and installs the patched code on pip 26.3 and on pip 25.1. The constraint's upstream hash does not conflict with it.
Expected
The module docs for crates/socket-patch-core/src/vendor/pypi_requirements.rs say the --hash is written "only when the requirements tree is already in pip's hash-checking mode … any --hash on any line turns that mode on for the whole install". A hash in a -c file turns that mode on too, so the vendor line should carry its --hash here. Failing that, the run should refuse or warn rather than leave a project that cannot install. "Do no harm" (a project that installed cleanly before must still do so afterwards) applies.
Actual
The vendor lines are unhashed. Every later pip install -r requirements.txt fails, and the scan, vendor --check and vex give no sign of it.
Versions (Linux)
| pip | baseline pip install -r (before scan) |
after scan --mode vendored |
|---|---|---|
| 26.3, 26.2.2, 26.1 | pass | fail |
| 26.0, 25.3, 25.2, 25.1, 25.0.1, 24.3.1, 24.2, 24.0, 23.3.2, 20.3.4 | fail (pip refuses hashed constraints next to an unhashed root) | fail (unchanged) |
| socket-patch | result |
|---|---|
main cfc870f |
reproduces |
| v5.1.0 | reproduces (not a regression; the layout only became installable with pip 26.1) |
Hosted mode on the same project is fine: the six @ <url>#sha256=… pin installs on pip 26.3 next to the hashed constraint.
Probably the same on macOS and Windows: it comes from the requirements-tree walk, not from anything platform-specific. Not tested there (Linux-only routine).
Suspect code
crates/socket-patch-core/src/vendor/pypi_requirements.rs:1209(plan_requirements) and:1397(the re-wire planner):let hashed = files.iter().any(|f| requires_hashes(&f.content));runs overcollect_requirements_files.crates/socket-patch-core/src/vendor/pypi_requirements.rs:1502:collect_requirements_filesdocuments that "-cconstraints files are never followed". That is right for editing them, but the hash-checking decision needs to read them too (and the-cfiles of includes, plusPIP_CONSTRAINT/ pip.confconstraint =if those are in scope).
The pip ledger's known-non-bugs list ruled this layout out earlier because "pip 24 refuses hashed constraints next to an unhashed root". That stopped being true with pip 26.1.
Generated by Claude Code
Activity
mikolalysenko commentedon Nov 30, 2026
[agent] More layouts that hit the same bug, from the scheduled pip / requirements.txt bug-hunt routine (ledger #309). Main
cfc870f, pip 26.3 / CPython 3.12, Linux. Each baselinepip install -r requirements.txtexits 0, and each post-scan install fails with "Hashes are required in --require-hashes mode, but they are missing from some requirements" whilevendor --checkexits 0:-c sub/constraints.txt(hashed) inside an-r base.txtinclude, unhashed pins in both filesbase.txtand inrequirements.txtPIP_CONSTRAINT=constraints.txt, unhashedrequirements.txtsix @ <url>#sha256=…next to-c constraints.txt, which installs patched), thensocket-patch vendorto ejectSo the fix needs to read the
-cfiles of includes too, and to cover the eject path, not justscan --mode vendored.PIP_CONSTRAINT(and pip.confconstraint =) live outside the project. Writing the vendored wheel's--hashwhenever a constraints source is in play would cover them, and on pip 26.3 that hash doesn't conflict with the constraint's upstream hash.Generated by Claude Code