nikivdev/code · error · anyhow::Error

No command specified

Error message

No command specified

What it means

Raised by the env-run (run-with-env) command when it is invoked without a trailing command to execute. This command fetches env vars and then spawns the given command with them injected, so an empty command list is a usage error caught before any network call.

Source

Thrown at src/env.rs:3897

                // Escape for shell
                let escaped = value.replace('\\', "\\\\").replace('"', "\\\"");
                println!("{}=\"{}\"", key, escaped);
            }
        }
    }

    Ok(())
}

/// Run a command with env vars injected from cloud.
fn run_with_env(
    personal: bool,
    environment: &str,
    keys: &[String],
    command: &[String],
) -> Result<()> {
    if command.is_empty() {
        bail!("No command specified");
    }

    let target = if personal {
        resolve_personal_target()?
    } else {
        resolve_env_target()?
    };
    let vars = fetch_env_vars(&target, environment, keys, !personal)?;

    let (cmd, args) = command.split_first().unwrap();

    let mut child = Command::new(cmd);
    child.args(args);

    // Inject env vars
    for (key, value) in &vars {
        child.env(key, value);
    }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Append the command after `--`: `f env run --environment prod -- node server.js`.
  2. Quote complex commands so the whole argv reaches the runner.
  3. Check shell alias/wrapper isn't stripping trailing arguments.

Example fix

// before
f env run --environment prod -- node
// after
f env run --environment prod -- node server.js
Defensive patterns

Strategy: validation

Validate before calling

# shell guard: require a command after --
args=$(...)
[ -n "$CMD" ] || { echo "usage: f env run [--env e] -- <command...>" >&2; exit 2; }

Prevention

When it happens

Trigger: Running `f env run --personal --environment prod` (or with keys) but omitting the `-- <command>` portion, e.g. missing the `--` separator so the CLI parses no command arguments.

Common situations: Forgetting the `--` separator before the command; quotes consuming the command; copying a docs example and dropping the command part.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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