xargs "No such file or directory" Errors
xargs runs the command itself, so a missing command produces an xargs error rather than a shell error.
Because xargs execs the command directly without a shell, builtins, aliases, pipes, and missing binaries fail in xargs-specific ways worth recognizing.
What it does
xargs locates the command on PATH and execs it directly. There is no shell in between, so shell features (pipes, redirects, builtins, aliases, variable expansion, globs) do not work inside the xargs command unless you wrap them in sh -c. A missing or non-executable binary surfaces as an xargs error.
Common usage
# WRONG: pipe is not interpreted, it is passed to echo
echo a | xargs echo hello | wc -l # fine, pipe is outside
# need shell features per item? wrap in sh -c
find . -name '*.gz' -print0 \
| xargs -0 -I {} sh -c 'gunzip -c "{}" | wc -l'Options
| Flag | What it does |
|---|---|
| sh -c '...' | Wrap the command so pipes/redirects/builtins work |
| -I {} | Place the item inside the sh -c script |
| (direct exec) | No shell: builtins and aliases are unavailable |
| (PATH) | The command must be a real executable on PATH |
In CI
Minimal runner images often lack a tool you assume is present, and the failure reads "xargs: <tool>: No such file or directory", which can look like a missing input file rather than a missing binary. Install the tool or invoke it by full path, and wrap any pipe or redirect in sh -c.
Common errors in CI
"xargs: foo: No such file or directory" means foo is not on PATH (or is a shell builtin xargs cannot exec). "xargs: bar: Permission denied" means the file exists but is not executable. Trying to use a pipe directly, like "xargs grep x | sort", does not error but sorts xargs output, not per-item output; use sh -c for per-item pipelines.