can1357/oh-my-pi · error · Error
Snippet file not found: ${resolved}
Error message
Snippet file not found: ${resolved} What it means
`omp ttsr test` reads the snippet from `--file <path>`. readSnippet resolves the path and checks existence with Bun.file before reading; if the resolved path does not exist it throws this error naming the absolute path. It prevents a silent empty-snippet test run.
Source
Thrown at packages/coding-agent/src/cli/ttsr-cli.ts:156
astConditions: string[];
astPrefilters: RegExp[];
astRequiresFullScan: boolean;
}
interface ScanFileCandidate {
path: string;
size?: number;
}
async function readSnippet(opts: { snippet?: string; file?: string }): Promise<string> {
if (opts.file) {
if (opts.file === STDIN_MARKER) {
return await Bun.stdin.text();
}
const resolved = path.resolve(opts.file);
const file = Bun.file(resolved);
if (!(await file.exists())) {
throw new Error(`Snippet file not found: ${resolved}`);
}
return await file.text();
}
if (opts.snippet !== undefined) return opts.snippet;
if (process.stdin.isTTY === false) return await Bun.stdin.text();
throw new Error("No snippet provided. Pass inline text, --file <path>, or pipe via --file -.");
}
function previewSnippet(text: string): string {
const single = text.replace(/\s+/g, " ").trim();
return single.length > 80 ? `${single.slice(0, 77)}…` : single;
}
function deriveLang(filePaths: string[] | undefined): string | undefined {
for (const filePath of filePaths ?? []) {
const ext = path.extname(filePath.replaceAll("\\", "/"));
if (ext.length > 1) return ext.slice(1).toLowerCase();
}View on GitHub (pinned to 9690622007)
Solutions
- Check the path printed in the error and fix the typo or run from the correct directory.
- Verify the file exists: `ls -l <path>` or `test -f <path>` before invoking.
- If you meant stdin, pass `--file -` (or omit --file and pipe input).
- If the file was moved, update the path or regenerate the snippet file first.
Example fix
// before omp ttsr test --file snipets/login.ts --rule rules/no-secrets.md // after omp ttsr test --file snippets/login.ts --rule rules/no-secrets.md
Defensive patterns
Strategy: validation
Validate before calling
import * as fs from "node:fs";
const resolved = path.resolve(opts.file);
if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) {
throw new Error(`Snippet file does not exist or is not a file: ${resolved}`);
} Try / catch
try {
await snippet(args);
} catch (err) {
if (err instanceof Error && err.message.startsWith("Snippet file not found:")) {
console.error(`Check --file path (cwd=${process.cwd()}): ${err.message}`);
}
throw err;
} Prevention
- Use absolute paths in scripts instead of cwd-relative ones.
- Quote shell variables and guard against empty expansion: "${SNIPPET_FILE:?unset}".
- Verify with `test -f "$FILE"` before invoking the CLI.
- Use `--file -` with a pipe when the content comes from another command.
When it happens
Trigger: Running `omp ttsr test --file <path> ...` where the path does not exist (typo, wrong working directory, deleted/moved file, or a path that only exists relative to a different cwd). Also when `--file` is anything other than `-` (stdin marker).
Common situations: Relative path typo from the wrong directory; pointing --file at a directory instead of a file; shell variable expanding to empty (e.g. `--file $SNIPPET` with SNIPPET unset); testing a rule against a file that was renamed in the repo.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Rule file not found: ${resolved}
- invalid template, {}; with --tmpdir, it may not be absolute
- invalid {} argument: {}
- invalid Zero increment value: {}
- ${name} path does not exist: ${trimmed}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/21ade5ba3748d914.
Report an issue: GitHub.