nikivdev/code · error

Usage: f hash <paths or unhash args>

Error message

Usage: f hash <paths or unhash args>

What it means

The `f hash` command wraps the external `unhash` binary. Its `run` entrypoint requires at least one argument (paths to hash or `unstash./`-prefixed unhash arguments). When `opts.args` is empty it bails immediately with this usage message before doing any work.

Source

Thrown at src/hash.rs:14

use std::env;
use std::io::IsTerminal;
use std::process::Command;

use anyhow::{Context, Result, bail};

use crate::cli::HashOpts;
use crate::env as flow_env;

const LINK_PREFIX: &str = "unstash./";

pub fn run(opts: HashOpts) -> Result<()> {
    if opts.args.is_empty() {
        bail!("Usage: f hash <paths or unhash args>");
    }

    let unhash_bin = which::which("unhash")
        .context("unhash not found on PATH. Run `f deploy-unhash` in the unhash repo.")?;

    let mut cmd = Command::new(unhash_bin);
    cmd.args(&opts.args);

    if env::var("UNHASH_KEY").is_err() {
        if let Ok(Some(value)) = flow_env::get_personal_env_var("UNHASH_KEY") {
            cmd.env("UNHASH_KEY", value);
        }
    }

    let output = cmd.output().context("failed to run unhash")?;
    if !output.status.success() {
        let stdout = String::from_utf8_lossy(&output.stdout);
        let stderr = String::from_utf8_lossy(&output.stderr);

View on GitHub (pinned to a747e741ae)

Solutions

  1. Pass one or more file paths to hash: `f hash src/main.rs src/lib.rs`
  2. Pass unhash-style arguments prefixed with `unstash./` if you intend to unhash instead
  3. Check your wrapper script actually forwards arguments (`f hash "$@"`, not `f hash`)

Example fix

# before
f hash
# after
f hash src/main.rs README.md
Defensive patterns

Strategy: validation

Validate before calling

if args.is_empty() {
    eprintln!("Usage: f hash <paths or unstash./ args>");
    std::process::exit(2);
}

Type guard

null

Try / catch

match hash::run(opts) {
    Err(e) if e.to_string().starts_with("Usage:") => {
        eprintln!("{e}");
        std::process::exit(2); // usage error, distinct exit code
    }
    r => r?,
}

Prevention

When it happens

Trigger: Invoking `f hash` with no arguments at all from the shell or a script.

Common situations: Typing the command without arguments to 'test' it; a wrapper script that forwards `$@` when the user supplied nothing; a pipeline where a glob failed to expand and produced zero arguments.

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


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/710733cce1c8fb1b. Report an issue: GitHub.