can1357/oh-my-pi · error · StatError
missing operand Try 'stat --help' for more information.
Error message
missing operand Try 'stat --help' for more information.
What it means
StatError::MissingOperand is thrown when the stat builtin is invoked with no file operands at all. stat requires at least one file (or '-' for stdin in filesystem mode) to report on, and the message follows the GNU convention of pointing the user at 'stat --help'.
Source
Thrown at crates/pi-builtins/src/stat.rs:138
-`%d`: free file nodes in file system
-`%f`: free blocks in file system
-`%i`: file system ID in hex
-`%l`: maximum length of filenames
-`%n`: file name
-`%s`: block size (for faster transfers)
-`%S`: fundamental block size (for block counts)
-`%t`: file system type in hex
-`%T`: file system type in human readable form
NOTE: your shell may have its own version of stat, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.";
#[derive(Debug, Error)]
enum StatError {
#[error("Invalid quoting style: {style}")]
InvalidQuotingStyle { style: String },
#[error("missing operand\nTry 'stat --help' for more information.")]
MissingOperand,
#[error("{directive}: invalid directive")]
InvalidDirective { directive: String },
#[error("cannot read table of mounted file systems: {error}")]
#[cfg_attr(not(unix), allow(dead_code, reason = "mount tables are unix-only"))]
CannotReadFilesystem { error: String },
#[error("using '-' to denote standard input does not work in file system mode")]
#[cfg_attr(not(unix), allow(dead_code, reason = "stdin filesystem mode is unix-only"))]
StdinFilesystemMode,
#[error("cannot read file system information for {file}: {error}")]
CannotReadFilesystemInfo { file: String, error: String },
#[error("cannot stat {file}: {error}")]
CannotStat { file: String, error: String },
}
mod options {
pub const DEREFERENCE: &str = "dereference";
pub const FILE_SYSTEM: &str = "file-system";View on GitHub (pinned to 9690622007)
Solutions
- Pass at least one file operand: `stat <file>`.
- Quote/default the path variable: `stat "${FILE:?path required}"` or `stat "${FILE:-.}"`.
- Check upstream command output if arguments are generated dynamically.
- Read `stat --help` for expected usage.
Example fix
// before FILE="" stat $FILE // after FILE="./target.txt" stat "$FILE"
Defensive patterns
Strategy: validation
Validate before calling
// require at least one operand before invoking stat
if (operands.length === 0) {
throw new Error("stat: missing operand — pass at least one file path");
} Try / catch
try {
await stat(args);
} catch (err) {
if (String(err).includes("missing operand")) {
// default to current directory entry or fail with a clear message
if (!file) throw new Error("no file given to stat");
return stat([file, ...args]);
} else throw err;
} Prevention
- Always quote path variables: stat "$FILE".
- Use ${FILE:?} in shell to abort on unset paths before invoking stat.
- Validate operand arrays are non-empty in wrappers before spawning.
- Set default paths where an empty operand is acceptable.
When it happens
Trigger: Running the stat builtin with only options and no path: `stat` or `stat --printf='%n'` with no positional argument.
Common situations: Shell variables holding paths that expanded to empty (`stat $UNSET_VAR`); pipelines where an upstream command produced no arguments; scripts that forgot a default path; wrapping code that drops empty args.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Invalid quoting style: {style}
- too many templates
- extra operand {} file operands cannot be combined with --fil
- multiple output files specified
- when reading file names from standard input, no file name of
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/5e5abd8ede905bda.
Report an issue: GitHub.