Hmbown/CodeWhale · error

current Codewhale executable path is not valid UTF-8

Error message

current Codewhale executable path is not valid UTF-8: {}

What it means

When spawning a workflow lane as a child process, the CLI re-executes its own binary and requires std::env::current_exe() to yield a valid UTF-8 path, since argv is built from Strings. If the executable path contains non-UTF-8 bytes (OsString conversion fails), this error is thrown.

Solutions

  1. Move/install the Codewhale binary to an ASCII/UTF-8-only path (e.g. /usr/local/bin or ~/.local/bin)
  2. Rename the offending directory segment to valid UTF-8
  3. Invoke via a UTF-8-safe symlink on PATH
  4. Report if your platform legitimately produces non-UTF-8 current_exe paths

Example fix

// before
$ /opt/codewhale-latin1-büff/etc/codewhale workflow run
// after
$ sudo mv /opt/codewhale-latin1-büff/etc/codewhale /usr/local/bin/codewhale
$ codewhale workflow run
Defensive patterns

Strategy: validation

Validate before calling

let exe = std::env::current_exe()?;
if std::str::from_utf8(exe.as_os_str().as_encoded_bytes()).is_err() {
    eprintln!("Codewhale is installed at a non-UTF-8 path; reinstall under a UTF-8 path before using workflows");
}

Type guard

fn is_utf8_path(p: &std::path::Path) -> bool {
    p.to_str().is_some()
}

Try / catch

match result {
    Err(e) if e.to_string().contains("not valid UTF-8") => {
        eprintln!("reinstall codewhale at a UTF-8-only path (e.g. /usr/local/bin)");
    }
    other => other?,
}

Prevention

When it happens

Trigger: The running binary lives at a path with non-UTF-8 bytes — e.g. a directory named with Latin-1/invalid bytes — and a workflow lane tries to spawn.

Common situations: Installing the CLI under a user or directory name containing unusual encodings, unusual mount points, or Windows paths with non-Unicode characters, then running a workflow.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/8db9036d188702be. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/lib.rs:1353

    });
    if let Some(token_budget) = token_budget {
        payload["token_budget"] = serde_json::json!(token_budget);
    }
    let input_json = serde_json::to_string(&payload)?;
    let passthrough = vec![
        "workflow-tool".to_string(),
        "--approval-source".to_string(),
        "explicit-workflow-command".to_string(),
        "--input-json".to_string(),
        input_json,
    ];
    let argv = {
        // Build argv with explicit config path like the previous dispatcher did.
        let mut args = Vec::new();
        let executable = std::env::current_exe()
            .context("resolve current Codewhale executable for workflow lane")?;
        let executable = executable.into_os_string().into_string().map_err(|path| {
            anyhow!(
                "current Codewhale executable path is not valid UTF-8: {}",
                PathBuf::from(path).display()
            )
        })?;
        args.push(executable);
        // config_path is the explicit workflow config path; prefer it over cli.config
        let cfg = Some(config_path);
        if let Some(cp) = cfg {
            args.push("--config".to_string());
            args.push(cp.display().to_string());
        } else if let Some(cp) = cli.config.as_deref() {
            args.push("--config".to_string());
            args.push(cp.display().to_string());
        }
        if let Some(profile) = cli.profile.as_ref() {
            args.push("--profile".to_string());
            args.push(profile.clone());
        }

View on GitHub (pinned to 73e0f67d83)