Ray's Knowledge Base
Unlock

A local test run hides tests that need an ambient git identity

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

Symptom#

Tests that make commits pass on the developer machine. On a CI runner with no git identity they fail.

Cause#

The developer's global git config supplies user.name and user.email. The tests rely on that identity and do not set their own.

Fix#

Run the suite locally with no identity, to find these tests:

GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.useConfigOnly GIT_CONFIG_VALUE_0=true cargo test --all-targets --no-fail-fast

Do not override HOME for this. rustup then loses its settings, and cargo prints nothing useful. Then give each failing test its own identity.

Evidence#

Seen in the rgit test suite on 2026-10-01. With this setup, a few tests (credentials, globals, scalar) fail because of the setup itself; ignore those. The fixes are the commits "test: set a git identity in the userdiff history test" and "test: give submodule commits an identity and cherry-pick a distinct parent".