can1357/oh-my-pi · error · LnError

missing destination file operand after {}

Error message

missing destination file operand after {}

What it means

The ln builtin's MissingDestination variant fires when only one operand is given and the default destination directory is unavailable. GNU ln treats a single argument as 'link into the current directory', but this build requires an explicit destination file path; without one it reports the missing operand after the quoted source.

Source

Thrown at crates/pi-builtins/src/ln.rs:62

#[derive(Clone, Debug, Eq, PartialEq)]
enum OverwriteMode {
	NoClobber,
	Interactive,
	Force,
}

#[derive(Error, Debug)]
enum LnError {
	#[error("target {} is not a directory", _0.quote())]
	TargetIsNotADirectory(PathBuf),

	#[error("")]
	SomeLinksFailed,

	#[error("{} and {} are the same file", _0.quote(), _1.quote())]
	SameFile(PathBuf, PathBuf),

	#[error("missing destination file operand after {}", _0.quote())]
	MissingDestination(PathBuf),

	#[error("extra operand {}\nTry '{} --help' for more information.", _0.quote(), _1)]
	ExtraOperand(OsString, String),

	#[error("{}: hard link not allowed for directory", _0.to_string_lossy())]
	FailedToCreateHardLinkDir(PathBuf),

	#[error("{0}")]
	Message(String),

	#[error("{0}")]
	Io(#[from] std::io::Error),
}


mod options {
	pub const FORCE: &str = "force";

View on GitHub (pinned to 9690622007)

Solutions

  1. Always pass an explicit destination: ln file.txt ./file.txt
  2. Fix the calling code to supply the destination path argument
  3. If cwd-linking is intended, resolve the destination explicitly (e.g. current_dir().join(filename))

Example fix

// before
ln(&host, &["file.txt"])?;
// after
ln(&host, &["file.txt", "./file.txt"])?;
Defensive patterns

Strategy: validation

Validate before calling

fn require_destination(args: &[&OsStr]) -> Result<(), &'static str> {
    if args.len() < 2 { return Err("ln requires a destination operand"); }
    Ok( )
}

Try / catch

match ln(&host, args) {
    Err(e) if e.to_string().starts_with("missing destination file operand") => eprintln!("usage: ln SOURCE DEST"),
    other => other?,
}

Prevention

When it happens

Trigger: Invoking ln with a single argument, e.g. `ln file.txt`, in a context where the implicit destination (current directory) cannot be resolved or is not supported by the host.

Common situations: Ported shell scripts that rely on GNU ln's single-operand 'link into cwd' behavior; hand-typed commands omitting the target.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/fbc2ebfc42503674. Report an issue: GitHub.