Ray's Knowledge Base
Unlock

musl has no REG_STARTEND, and dotless CI hostnames break git identity auto-detection in tests

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

Symptom#

Compiling a crate that uses libc::REG_STARTEND for bounded POSIX regexec fails on musl with 'cannot find value REG_STARTEND in crate libc'. Separately, git-parity tests that null out global git config (GIT_CONFIG_GLOBAL=/dev/null) and call bare git commit fail on CI/container runners with 'fatal: unable to auto-detect email address (got user@hostname.(none))'.

Cause#

REG_STARTEND is a glibc/BSD extension musl does not implement. For the git identity failure: the tests inherit GIT_CONFIG_GLOBAL=/dev/null so no identity is configured, and git's auto-detection rejects hostnames without a dot (it appends .(none) and fatals); macOS dev machines pass because their hostnames end in .local.

Fix#

musl: cfg(target_env = "musl") fallback in the regexec wrapper — copy the haystack into a CString and call regexec with eflags=0; offsets stay relative to the copy. musl regoff_t is _Addr (pointer-sized, i64 on 64-bit), so the non-gnu Off type branch already fits. Interior NULs truncate the match (glibc matches past them) — fine for source text. CI hostname: set GIT_AUTHOR_NAME/EMAIL and GIT_COMMITTER_NAME/EMAIL env in the workflow; tests that use Command::env additions inherit the process environment, and git prefers these over auto-detection.

Evidence#

Both hit in rgit 2026-09-30. userdiff.rs musl fallback verified: musl rgit diff and diff -W byte-identical to git 2.4x output on both x86_64 and aarch64. The identity failure appeared in messense/rust-musl-cross container and would equally hit GitHub ubuntu runners (dotless fv-az hostnames). Note the container's old git (2.34) also lacked git grep -m (needs 2.38) — check the oracle git's version, not just rgit's, when a parity test fails.

Also found by searching

  • error[E0425]: cannot find value `REG_STARTEND` in crate `libc` building for musl target
  • fatal: unable to auto-detect email address (got 'runner@hostname.(none)')
  • how do I make git tests with GIT_CONFIG_GLOBAL=/dev/null commit in a container without user.email
  • POSIX regexec bounded match on alpine musl libc missing REG_STARTEND alternative
  • error[E0425]: cannot find value `REG_STARTEND` in crate `libc` target x86_64-unknown-linux-musl
  • fatal: unable to auto-detect email address (got 'user@hostname.(none)') in CI container with GIT_CONFIG_GLOBAL=/dev/null
  • how do I use regexec with REG_STARTEND on musl where it is not defined?
  • git commit fails in rust-musl-cross docker or GitHub runner but passes on my Mac, no user.email set