aaif-goose/goose · error

Empty editor command

Error message

Empty editor command

What it means

The configured editor command, after splitting, produced zero tokens — it is empty or contains only whitespace. launch_editor refuses to spawn an empty program. This means the editor setting (GOOSE_EDITOR / editor in config / EDITOR fallback) was never set or was set to a blank value.

Source

Thrown at crates/goose-cli/src/session/editor.rs:164

/// whitespace to avoid shlex stripping backslashes from Windows paths like
/// `C:\Windows\System32\notepad.exe`.
fn split_editor_command(editor_cmd: &str) -> Result<Vec<String>> {
    if editor_cmd.contains(['"', '\'']) {
        shlex::split(editor_cmd).ok_or_else(|| {
            anyhow::anyhow!("Invalid editor command: unmatched quotes in '{editor_cmd}'")
        })
    } else {
        Ok(editor_cmd.split_whitespace().map(String::from).collect())
    }
}

/// Launch editor and wait for completion
fn launch_editor(editor_cmd: &str, file_path: &PathBuf) -> Result<()> {
    use std::process::Stdio;

    let parts = split_editor_command(editor_cmd)?;
    if parts.is_empty() {
        return Err(anyhow::anyhow!("Empty editor command"));
    }

    let mut cmd = Command::new(&parts[0]);
    if let Ok(cwd) = std::env::current_dir() {
        cmd.current_dir(cwd);
    }
    if parts.len() > 1 {
        cmd.args(&parts[1..]);
    }
    cmd.arg(file_path)
        .stdin(Stdio::inherit())
        .stdout(Stdio::inherit())
        .stderr(Stdio::inherit());

    let status = cmd.status()?;

    if !status.success() {
        return Err(anyhow::anyhow!(

View on GitHub (pinned to 3810898a74)

Solutions

  1. Set an editor: `goose config set editor vim` or export EDITOR=nano in your shell profile.
  2. Check for and remove an empty editor entry in the goose config file.
  3. Verify with `goose config get editor` before retrying the command.

Example fix

# before
$ goose recipe edit   # or any editor-opening flow
Error: Empty editor command

# after
$ goose config set editor vim
$ goose recipe edit
Defensive patterns

Strategy: validation

Validate before calling

# ensure an editor is configured before any editor-opening flow
[ -n "${GOOSE_EDITOR:-${EDITOR:-}}" ] || { echo 'set editor: goose config set editor vim'; exit 1; }

Type guard

fn editor_configured(cmd: &str) -> bool {
    cmd.split_whitespace().next().is_some()
}

Try / catch

if let Err(e) = launch_editor(&editor_cmd, &file) {
    if e.to_string() == "Empty editor command" {
        eprintln!("configure an editor first: `goose config set editor <cmd>`");
    }
    return Err(e);
}

Prevention

When it happens

Trigger: Invoking a command that opens $EDITOR (e.g. editing a recipe or message in an interactive goose prompt) when the editor config is "" or unset-but-defaulted-to-empty; a config file with `editor = ''`.

Common situations: Minimal containers or fresh shells with EDITOR unset; config migrations wiping the editor key; CI/non-login shells lacking profile exports.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/7c3d58fa11d410bc. Report an issue: GitHub.