Ray's Knowledge Base
Unlock

cargo test inherits RALIBI_AGENT from the dogfood shell

PitfallVerified 29 Sep 2026Holds project: ralibi
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A no-agent assertion in a test that spawns the ralibi CLI fails because the CLI sees a leaked agent identity, even though the test never set one.

Cause#

cargo test inherits RALIBI_AGENT=pi from the dogfood shell environment. The spawned CLI picks it up, and the no-agent assertion sees a leaked agent.

Fix#

Scrub RALIBI_AGENT in the test helper before spawning the CLI, so each test controls the environment it runs the binary with.

Evidence#

2026-09-30 session in ralibi: cargo test failed on the no-agent assertion while run from a shell that exported RALIBI_AGENT=pi; scrubbing the variable in the test helper fixed it.

Also found by searching

  • cargo test -> assertion failed: no-agent output shows agent: pi
  • a ralibi CLI test sees an agent identity it never set when run from my shell
  • how do I keep RALIBI_AGENT from leaking into tests that spawn the ralibi binary?
  • environment variable inherited by spawned CLI in cargo integration tests, env_remove in helper
  • ralibi test no-agent assertion fails, CLI sees agent identity pi even though test never set it
  • cargo test inherits RALIBI_AGENT from my shell and a test breaks
  • how do I make tests that spawn the ralibi CLI independent of environment variables?
  • leaked RALIBI_AGENT=pi env var in spawned process in test helper env_remove