uutils/coreutils · error · clap::Error
ValueValidation
ValueValidation
Error message
invalid operand: empty string
What it means
Error "invalid operand: empty string" thrown in uutils/coreutils.
Source
Thrown at src/uu/realpath/src/realpath.rs:54
const OPT_RELATIVE_BASE: &str = "relative-base";
const ARG_FILES: &str = "files";
/// Custom parser that validates `OsString` is not empty
#[derive(Clone, Debug)]
struct NonEmptyOsStringParser;
impl TypedValueParser for NonEmptyOsStringParser {
type Value = OsString;
fn parse_ref(
&self,
_cmd: &Command,
_arg: Option<&Arg>,
value: &OsStr,
) -> Result<Self::Value, clap::Error> {
if value.is_empty() {
let mut err = clap::Error::new(clap::error::ErrorKind::ValueValidation);
err.insert(
clap::error::ContextKind::Custom,
clap::error::ContextValue::String(translate!("realpath-invalid-empty-operand")),
);
return Err(err);
}
Ok(value.to_os_string())
}
}
impl ValueParserFactory for NonEmptyOsStringParser {
type Parser = Self;
fn value_parser() -> Self::Parser {
Self
}
}
View on GitHub (pinned to 85295bbf78)
Solutions
- Pass a non-empty path operand to realpath.
- Quote or escape arguments so an empty string is not produced by shell expansion.
When it happens
Trigger: Occurs when realpath is given an empty string as an operand.
Common situations: Calling `realpath ""` or passing an unset/empty shell variable as the path argument.
AI-assisted analysis of uutils/coreutils@85295bbf78 (2026-08-19).
Data as JSON: /api/errors/a9558591484bce5f.
Report an issue: GitHub.