Ray's Knowledge Base
Unlock

prek stashes unstaged files, so a check that passes directly can fail under prek

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

Symptom#

A test passes when run directly, for example with cargo test. The same test fails under prek run. The error is about missing changes, such as a tool that was added but is not in an audit list.

Cause#

prek stashes unstaged files while its hooks run. Unstaged edits, such as Rust changes made next to staged extension files, vanish during the check. The check then sees an incomplete tree.

Fix#

Stage every changed file by name before prek run. Do not use stage-all, because the global git ignore hides some files from it. Run prek run again after staging.

Evidence#

In the CHG-avnr08 judge work, the Rust audit test passed directly but failed under prek. The agent found that prek stashed its unstaged Rust changes mid-check, staged everything by name, and prek went green.