Ray's Knowledge Base
Unlock

cargo test in rgit fails to link against the system libgit2; build vendored with LIBGIT2_NO_PKG_CONFIG=1

PitfallVerified 13 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

On this machine, cargo test for rgit-cli and rgit-git fails with a link error. Listing tests with cargo test -p rgit-cli --tests -- --list also fails, so a test count grep returns 0 and the command exits 1. Trying a static link instead fails because llhttp is missing.

Cause#

The system libgit2 dylib hides two symbols that the code calls. The static lib has them but lacks llhttp. The build picks up the system libgit2 through pkg-config.

Fix#

Set LIBGIT2_NO_PKG_CONFIG=1 on every cargo and rvow command so the vendored libgit2 is built. Example: LIBGIT2_NO_PKG_CONFIG=1 rvow prove TSK-wdz1f9. Use the same value for the baseline and the final test counts so they stay comparable.

Evidence#

The agent saw the dylib hide two symbols and the static link lack llhttp, then set the variable and the vendored build worked. After that, the rgit-cli prove run passed 391 tests and the rgit-git prove run passed 138 tests. The final report says: Plain cargo test fails to link on this machine.