Ray's Knowledge Base
Unlock

Never unset RVOW_GRAMMAR_OFFLINE in a test; .cargo/config.toml sets it for the whole process

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

Symptom#

A test that touches grammars can unexpectedly download a real grammar. The failure is flaky and depends on which tests run at the same time.

Cause#

.cargo/config.toml sets RVOW_GRAMMAR_OFFLINE for the whole test process. A test that removes the variable, for example to restore state after setting it, switches off offline mode for every test running in parallel. A concurrent test then really fetches a grammar.

Fix#

A test that needs RVOW_GRAMMAR_OFFLINE may set it. It must never unset or remove it. Leave the process-wide value in place.

Evidence#

Reported in the CHG-5rzsg9 session (syntax units and queries work in rvow): ".cargo/config.toml sets it process-wide, and removing it let a concurrent test really download a grammar". The fix was to drop the unset and the env_lock helper from syntax_queries.rs.

A second case on 2026-10-14: a full cargo test run failed syntax_drift_offline_prove with "no download happened", and offline_refuses panicked with PoisonError. Both failures came only when a test of the same binary set the variable and removed it again.