Repository navigation
Description
[agent] Filed by the architecture refactor routine. Checked on main at cfc870f with the built binary, git 2.43.0, cargo 1.97.0, Go 1.24.7 and Bundler on Ruby 3.3.6.
Kind: bug. A vendored run reports success and vendor --check reports "committed artifact and wiring verified" for a tree git will only partly commit. The same class was fixed for tarballs, jars, nupkgs, wheels and platform gems (#831, #1061, #1116, #1572, #2154); the directory trees of Cargo, Go and a plain gem were left out.
Problem
A vendored run ends with Commit .socket/vendor/ and the updated lockfiles to make the patches portable. For Cargo, Go, a plain gem and Composer the artifact is a directory of the package's own files. Nothing asks git whether it will commit each file of that directory. Two kinds of rule drop files from the commit:
- The package's own
.gitignore, which travels inside the copy. A crate ships aCargo.lockthatcargo packagegenerates, and its own.gitignorenamesCargo.lock. A Go module ships fixtures under a directory its.gitignorenames. - The project's
.gitignore. GitHub's stockRust.gitignorehastargetanddebug,Go.gitignorehas*.test,*.outand*.exe, andRails.gitignorehas.rspec. Each matches files that real packages ship.
The checkout that ran vendor keeps every file, so it builds and verifies there. Every other checkout gets the tree without them.
Evidence
Each project below is a real one: cargo init, go mod tidy or bundle install from the public registry, then one patch record and blob, then socket-patch vendor against the repository's fixture vendor service (tests/prebuilt_common, which packs the package as the registry extracted it).
Cargo, the crate's own .gitignore (cfg-if 1.0.4; the project's .gitignore is the /target that cargo init writes):
$ socket-patch vendor
Vendored 1 package.
Next steps:
1. Commit .socket/vendor/ and the updated lockfiles to make the patches portable.
$ git status --short --ignored | grep '^!!'
!! .socket/vendor/cargo/<uuid>/cfg-if-1.0.4/Cargo.lock
$ socket-patch vendor --check
pkg:cargo/cfg-if@1.0.4: committed artifact and wiring verified # exit 0
$ git add -A && git commit -qm vendor && git clone -q . ../clone && cd ../clone
$ cargo build --locked --offline # exit 0, links the patched copy
$ socket-patch vendor --check
pkg:cargo/cfg-if@1.0.4: committed artifact .socket/vendor/cargo/<uuid>/cfg-if-1.0.4 has files that differ from its recorded inventory (vendor_inventory_mismatch); run `socket-patch repair` to restore it, then commit it # exit 1
$ socket-patch vex --product pkg:generic/app@1.0.0 -O vex.json
Warning: omitting pkg:cargo/cfg-if@1.0.4 from VEX: the vendored artifact's contents do not match its ledger inventory (vendor_inventory_mismatch)
Error: No applied patches with vulnerability metadata to attest. # exit 1, no document
$ socket-patch repair # the remedy
Redownloaded 1 vendored artifact.
$ git add -A && git diff --cached --name-only | wc -l
0 # nothing to commit: the next clone fails again
Cargo, GitHub's Rust.gitignore in the project (cc 1.2.56 as a build dependency):
$ socket-patch vendor # exit 0, "Vendored 1 package."
$ git status --short --ignored | grep '^!!'
!! .socket/vendor/cargo/<uuid>/cc-1.2.56/Cargo.lock
!! .socket/vendor/cargo/<uuid>/cc-1.2.56/src/target/
$ socket-patch vendor --check # exit 0, "committed artifact and wiring verified"
$ git add -A && git commit -qm vendor && git clone -q . ../clone && cd ../clone
$ cargo build --locked --offline
Compiling cc v1.2.56+socket.3c4d5e6f-… (…/.socket/vendor/cargo/<uuid>/cc-1.2.56)
error[E0583]: file not found for module `apple`
--> .socket/vendor/cargo/<uuid>/cc-1.2.56/src/target.rs:4:1
error[E0583]: file not found for module `generated`
… # exit 101
The project built before it was vendored and builds in the checkout that vendored it. It stops building in CI.
Go, the module's own .gitignore (github.com/pelletier/go-toml/v2 v2.4.3, whose .gitignore has fuzz/; the project has no .gitignore):
$ socket-patch vendor # exit 0
$ git status --short --ignored | grep '^!!'
!! .socket/vendor/golang/<uuid>/github.com/pelletier/go-toml/v2@v2.4.3/testdata/
$ socket-patch vendor --check # exit 0, verified
# after the commit, in a fresh clone:
$ GOPROXY=off go build ./... # exit 0
$ socket-patch vendor --check # exit 1, vendor_inventory_mismatch
$ socket-patch vex --product pkg:generic/app@1.0.0 -O vex.json # exit 1, no document
A plain gem, GitHub's Rails.gitignore in the project (rest-client 2.1.0): git ignores .socket/vendor/gem/<uuid>/rest-client-2.1.0/.rspec. In a fresh clone a frozen bundle install and bundle exec ruby -e 'require "restclient"' load the patched copy, vendor --check exits 1 (vendor_inventory_mismatch) and vex exits 1 with no document.
How common. Each package copied to its vendored path in an empty repository, then git ls-files -o -i --exclude-standard:
| Packages | No project .gitignore |
GitHub's stock template in the project |
|---|---|---|
| 229 crates (this repository's dependencies, as cargo extracted them) | 65 lose a file; 63 of them Cargo.lock, among them h2, http, bytes, tar, smallvec, hashbrown, serde_json, hyper-util |
Rust.gitignore: also source files of cc (src/target/*.rs) and winnow (src/combinator/debug/*.rs, a mod debug; with no cfg), and tests of syn |
| 59 Go modules (the latest of well-known ones) | 4: go-toml/v2, docker/distribution, hashicorp/go-getter (two .go files of its command), open-policy-agent/opa |
Go.gitignore: 8, adding golang.org/x/net v0.63.0 (14 .test fixtures), golang.org/x/sys, containerd, klauspost/compress |
| 58 gems (popular ones, unpacked) | 0 | Rails.gitignore: 2 (rest-client, rspec-core); Ruby.gitignore: 0 |
Agent mode is not affected by the Go case: with the same module in .socket/go-patches/, apply --check and apply pass in a fresh clone, because they hash only the patched files.
Not run: Composer (the copy's own .gitignore is already emptied there, for Composer's path mirror; the project's rules are not asked about), and the patch service itself. This sandbox has no route to it, so what the fixture packs stands in for its artifact. The second kind of rule does not depend on that: a crate cannot compile without the files Rust.gitignore matches.
Where
- CLI
commands/vendor.rs, lines 1608 to 1620:artifacts_gitignore_checkedlists the backends that ask git per package (npm, NuGet, PyPI, the JVM trees) and says "The others rely on the run-level ledger check". - core
vendor/state.rs, lines 1067 to 1100: that check,ledger_gitignore_refusal, asks git about two paths,.socket/vendor/and the ledger. - core
vendor/gem.rs:keep_platform_trees_committable(line 1957) asks git about every file of the inventory,empty_shipped_gitignores(line 1820) empties a.gitignoreshipped inside the tree, andUUID_GITIGNORE(line 1938) is the!*written beside it. All three run only for a gem locked as platform gems. - core
vendor/cargo.rsandvendor/golang.rshave no ignore handling at all. - The fresh-checkout proofs of the real-tool suites cannot see this:
tests/e2e_vendor_cargo_build.rs(lines 757, 1040 and 1208) copies a hand-picked list of "committable files" to a new directory instead of committing and cloning.
Earlier fixes of the class: 6fa6a9e (npm tarballs, #831), eca5d24 (JVM and NuGet, #1061), debe1c0 (PyPI wheels, #1572), 9d54302 (the ledger, #1638), d16c589 (platform gems, #2154).
Planned fix
Give every directory-tree backend what platform gems have, from one shared function rather than a fifth copy:
- Write
<uuid>/.gitignore(!*) and the.gitattributesthe other backends write. With real git this re-includescc'ssrc/target/underRust.gitignore. - Empty each
.gitignoreshipped inside the copy, as the platform-gem and Composer backends do (a deeper.gitignorewins over the!*above it; withcc's emptied, git no longer ignores itsCargo.lock). The ledger's inventory is of the copy as vendored. - Ask git about every file of the inventory after the write, and refuse
vendor_artifact_gitignoredwhen a rule still wins. - Have an in-sync re-run and
repairput the pair back, so a tree vendored before the fix heals. - Make the Cargo, Go and gem fresh-checkout tests go through
git add -A,git commitandgit clone, with the stock template in the project.
The .gitattributes of step 1 also covers the vendored trees of #2318's comment (line-ending conversion of the same Go, Cargo and Composer directories).
Behavior change: a vendored Cargo, Go, gem or Composer directory gains the two files beside it, and a .gitignore inside the copy is emptied. CLI_CONTRACT.md's rows for those four backends and for vendor_artifact_gitignored need the same sentences the platform-gem row has.
Generated by Claude Code
Activity
refactor: #2348, #2349 and #2351 filed; ignore rules ran
mikolalysenko commentedon Dec 1, 2026
[agent] The Composer row this issue lists as not run, run on
mainat 1b3f422 with the built binary, git 2.43.0, Composer 2.8.12 and PHP 8.3.6. It is the same defect: a project.gitignorerule keeps a file of the vendored Composer directory out of the commit,vendorandvendor --checkreport success, and every fresh clone installs the package without that file.Evidence
A real project that requires
composer/ca-bundle1.5.6, whose dist shipsres/cacert.pem. The project's.gitignoreis/vendor/,*.pemand*.key(rules that keep private keys out of a repository). One patch record and blob (a comment appended tosrc/CaBundle.php), thensocket-patch vendoragainst the repository's fixture vendor service (tests/prebuilt_common), as in the rows above.composer installexits 0 in the clone, so nothing says the package is short a file until the application asks for the bundle. The checkout that ranvendorkeeps the file and works.Control. The same project with the
*.pemrule taken out: git commitsres/cacert.pem, the clone'scomposer installgivesfile_existstrue,vendor --checkexits 0 andvexwrites one statement.Step 1 of the planned fix covers Composer. With
.socket/vendor/composer/<uuid>/.gitignoreholding!*, written by hand beside the copy and under the same*.pemrule, git commitsres/cacert.pem. In the clone Composer's mirror copies it,file_existsis true,vendor --checkexits 0 with that extra file in the uuid directory, andvexwrites one statement.How common
78 packages: 24 well-known ones picked by hand (several because I expected a match) and what they require. Each file of a package's dist (
git archive HEAD, which appliesexport-ignore) at its vendored path, 7,498 files, against one rule at a time withgit check-ignore:*.pemcomposer/ca-bundle(res/cacert.pem),paragonie/certainty(19 bundles)*.crtstripe/stripe-php(data/ca-certificates.crt),braintree/braintree_php(lib/ssl/…ca.crt),tecnickcom/tcpdfdist/twbs/bootstrap(96 files: all of its compiled CSS and JS),paragonie/random_compat*.mapdompdf/php-font-lib(21maps/*.mapencoding tables),twbs/bootstrap,components/jquery*.min.jscomponents/jquery,twbs/bootstrap,filp/whoopsbin/nesbot/carbon,symfony/console(Resources/bin/hiddeninput.exe),symfony/translation,masterminds/html5,paragonie/certaintybuild/,docs/,tmp/twbs/bootstrap,psr/http-message,mpdf/mpdf*.key,*.log,*.zip,*.sql,.env,temp/,cache/,node_modules/Where
commands/vendor.rs, line 1713:artifacts_gitignore_checkednames npm, NuGet, PyPI and the JVM trees. Composer is among "the others", which get the run-level check of.socket/vendor/and the ledger alone (corevendor/state.rs,ledger_gitignore_refusal, line 1067).vendor/composer_lock.rsasks git about no file of the copy and writes no<uuid>/.gitignore. What it does empty is the copy's own.gitignore, for Composer's mirror.So the shared function of the planned fix has four callers, not three: Cargo, Go, a plain gem and Composer.
Not run: the patch service itself (the fixture packs the package as installed, as in the rows above). Composer could not reach the dist host from this sandbox and installed from source, so I gave
vendor/composer/ca-bundlethe dist's file list withgit archive HEADand setinstallation-sourcetodistbefore vendoring. Which stock.gitignoretemplates carry each rule of the table was not looked up. A line-ending rule on the same tree is #2318's first comment.Generated by Claude Code
refactor: L125 on #2348; file modes examined