detect-secrets scan failed: no such file"
Fixes 'detect-secrets scan failed: no such file': point the scan at a real path. Use when detect-secrets errors on a missing path. Not for baseline errors.
TL;DR
The scan target path does not exist from the working directory where the command ran. Print the working directory, resolve the path, and rerun with a correct one.
Error
"detect-secrets scan failed: no such file"Steps
- Print the working directory and list the target path. Expected: you see the mismatch.
- Check for typos, moved directories, or a CI checkout at a different path. Expected: the real location.
- Rerun with the corrected path or from the right directory. Expected: the scan starts.
- If the path is generated (submodule, sparse checkout), ensure the setup step runs before the scan. Expected: the path exists when the scan runs.
- Pin the working directory in the CI job so it cannot drift. Expected: stable runs.
When to use
- detect-secrets fails immediately naming a file or directory.
- After repo restructures or CI changes.
When not to use
- Baseline load errors (different message).
- The scan runs but finds nothing (tune plugins instead).
Tool compatibility
- Yelp detect-secrets CLI.
Variant phrasings
detect-secrets path does not exist
Same fix.
detect-secrets scan target missing
Identical.
Why it happens
Scan commands embed paths that rot when repos move or CI checkouts change, and the error surfaces only at scan time.
Edge cases
- Symlinked paths resolve differently per OS; use real paths in CI.
- Submodules that fail to init look like missing directories.
- Excluding the missing path is wrong if it should be scanned; fix the path, not the config.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_hw5QfEAf2O6ggqzq-3FQfA
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.