Ray's Knowledge Base
Unlock

A test helper that returns paths must keep its TempDir alive

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

Symptom#

Later operations in a test fail with .lock: No such file.

Cause#

The helper returns paths from a TempDir but drops the TempDir, which deletes the directory on return.

Fix#

Return the TempDir too and keep it alive for the whole test case.

Evidence#

Observed note, 2026-10-03, rvow tests (accepted() helper).

Also found by searching

  • .lock: No such file or directory in a rust test using a helper
  • TempDir deleted when helper returns paths
  • rust test helper returns path of temporary directory that vanishes