Try the demo

rg: The system cannot find the file specified. (os error 2)

A file or folder you named isn't there, often because the path was a guess.

The error

$ rg retries src/config.ts
rg: src/config.ts: IO error for operation on src/config.ts: The system cannot find the file specified. (os error 2)

Given several paths, rg names the missing one more briefly, and still searches the rest:

$ rg -n retries src/main.ts src/config.ts
rg: src/config.ts: The system cannot find the file specified. (os error 2)
src/main.ts:1:import { retries } from "./lib/config";

On Linux and macOS the same error reads No such file or directory (os error 2).

Why it happens

rg searches exactly the paths you give it. When one doesn't exist, it says so and exits with status 2, even if it found matches in the others, and --no-messages hides the message but not the status. A script that reads 0 as found and 1 as not found sees an error instead.

Coding agents hit it when they name the file they expect, src/config.ts, rather than the one there is, src/lib/config.ts. It's the same habit as Get-Content's Cannot find path.

The fix

Find the file by name, or search its folder and let rg find it:

rg --files -g '*config*'          # src\lib\config.ts
rg -n retries src -g '*.ts'       # every .ts file under src

A glob given as a path fails differently on Windows, where no shell expands it: os error 123, also fixed with -g.

How DMN learned it

It came up, and was fixed, in 7 of our own sessions, and in 4 more under two other lessons. DMN kept the fix as one line: rg fails with 'cannot find the file specified (os error 2)' when given guessed file paths; search a parent directory with --glob, or confirm names via rg --files, before naming specific files.

DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.

Stop fixing the same error twice