tinyhumansai/openhuman · error · anyhow::Error

missing --workspace

Error message

missing --workspace

What it means

Flag parser `parse_workspace_flag` (src/core/subconscious_cli.rs:233) requires a value after `--workspace` / `-w`; when the flag is the last token, `args.get(i + 1)` is None and this error fires. It is purely positional — a value that begins with `--` would still be consumed as the value.

Source

Thrown at src/core/subconscious_cli.rs:233

            "interval_minutes": mode.default_interval_minutes().max(5),
        });

        println!("{}", serde_json::to_string_pretty(&status)?);
        Ok(())
    })
}

// ── helpers ────────────────────────────────────────────────────────────────

fn parse_workspace_flag(args: &[String]) -> Result<Option<PathBuf>> {
    let mut workspace: Option<PathBuf> = None;
    let mut i = 0;
    while i < args.len() {
        match args[i].as_str() {
            "--workspace" | "-w" => {
                workspace = Some(PathBuf::from(
                    args.get(i + 1)
                        .ok_or_else(|| anyhow!("missing --workspace"))?,
                ));
                i += 2;
            }
            other => return Err(anyhow!("unknown flag '{other}'")),
        }
    }
    Ok(workspace)
}

fn is_help(s: &str) -> bool {
    matches!(s, "--help" | "-h" | "help")
}

fn print_help() {
    eprintln!(
        "Usage: openhuman subconscious <command> [options]

Commands:

View on GitHub (pinned to a221052e0d)

Solutions

  1. Supply the path: `--workspace /path/to/dir` or `-w /path/to/dir`.
  2. In scripts, guard: only append the flag when the variable is non-empty (`[ -n "$WS" ] && set -- "$@" --workspace "$WS"`).
  3. If you did not intend to set a workspace, drop the flag — the default workspace from config is used.

Example fix

# before
openhuman subconscious status --workspace
# after
openhuman subconscious status --workspace ~/.openhuman/users/me
Defensive patterns

Strategy: validation

Validate before calling

// Script-level guard: only append the flag when a value exists
// POSIX sh:
//   [ -n "$WS" ] && set -- "$@" --workspace "$WS"
// Rust builder:
let mut cmd = Command::new(bin);
if let Some(ws) = workspace.filter(|s| !s.trim().is_empty()) {
    cmd.arg("--workspace").arg(ws);
}

Prevention

When it happens

Trigger: `openhuman subconscious status --workspace` (no path after), or `-w` at end of args; also a shell script where the workspace variable expanded to nothing and the flag was left dangling.

Common situations: Empty `$WORKSPACE` env var in scripts (`-w "$WORKSPACE"` with WORKSPACE unset still passes an empty string — the dangling-flag case is when the argument list itself ends); truncated command lines from copy-paste; CI matrix jobs where the workspace param is optional and was omitted without removing the flag.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16). Data as JSON: /api/errors/694ab3c31b83a1e9. Report an issue: GitHub.