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
- Pass one or more file paths to hash: `f hash src/main.rs src/lib.rs`
- Pass unhash-style arguments prefixed with `unstash./` if you intend to unhash instead
- 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
- Check argument count in your wrapper before dispatching to subcommands
- Quote globs properly so empty expansions are detected (`$#` count check in shell)
- Always print usage text on empty args in CLI entrypoints
- Use clap or a similar arg parser to get automatic usage enforcement
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
- Usage: f migrate <target> OR f migrate <source> <target> OR
- No prompt provided. Usage: f agents run {} "your prompt here
- enable-global is only supported for Codex sessions; use `f c
- missing prompt. Usage: f ai everruns "your prompt"
- Project mismatch. Bundle is for '{}' but this repo is '{}'.
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/710733cce1c8fb1b.
Report an issue: GitHub.