aaif-goose/goose · error

Failed to get recipe file content: {}

Error message

Failed to get recipe file content: {}

What it means

std::process::Command::new("gh").output() itself failed at the OS level when fetching an individual recipe file — the gh executable could not be spawned. This is not an HTTP error; it means the process never ran, almost always because `gh` is not on PATH in the environment goose runs in.

Source

Thrown at crates/goose-cli/src/recipes/github_recipe.rs:341

        }
    }

    Err(anyhow!("No recipe file found in directory: {}", dir_name))
}

fn get_github_recipe_info(repo: &str, dir_name: &str, recipe_filename: &str) -> Result<RecipeInfo> {
    use serde_json::Value;
    use std::process::Command;

    // Get the recipe file content
    let output = Command::new("gh")
        .args([
            "api",
            &format!("repos/{}/contents/{}/{}", repo, dir_name, recipe_filename),
        ])
        .set_no_window()
        .output()
        .map_err(|e| anyhow!("Failed to get recipe file content: {}", e))?;

    if !output.status.success() {
        return Err(anyhow!(
            "Failed to access recipe file: {}/{}",
            dir_name,
            recipe_filename
        ));
    }

    let file_info: Value = serde_json::from_slice(&output.stdout)
        .map_err(|e| anyhow!("Failed to parse file info: {}", e))?;

    if let Some(content_b64) = file_info.get("content").and_then(|c| c.as_str()) {
        // Decode base64 content
        use base64::{engine::general_purpose, Engine as _};
        let content_bytes = general_purpose::STANDARD
            .decode(content_b64.replace('\n', ""))
            .map_err(|e| anyhow!("Failed to decode base64 content: {}", e))?;

View on GitHub (pinned to 3810898a74)

Solutions

  1. Verify with `which gh`; if missing, install it (brew install gh / apt install gh) or activate the environment that provides it.
  2. If launching goose from a GUI or service, ensure PATH includes gh's install location (e.g. /usr/local/bin, /opt/homebrew/bin).
  3. Re-run the goose command from a shell where `gh --version` works.

Example fix

# before
$ goose recipe info owner/repo/my-recipe
Error: Failed to get recipe file content: No such file or directory (os error 2)

# after
$ brew install gh   # or: apt install gh
$ which gh && gh --version
$ goose recipe info owner/repo/my-recipe
Defensive patterns

Strategy: validation

Validate before calling

use std::process::Command;
fn gh_available() -> bool {
    Command::new("gh").arg("--version").output().map(|o| o.status.success()).unwrap_or(false)
}
// call gh_available() before any recipe-from-GitHub flow

Try / catch

match run() {
    Err(e) if e.to_string().contains("Failed to get recipe file content") => {
        eprintln!("gh CLI not spawnable — install gh or fix PATH");
    }
    r => r,
}

Prevention

When it happens

Trigger: Executing goose recipe loading in a shell/container/GUI-launched process whose PATH does not include the GitHub CLI binary; gh installed via a method (e.g. hermit) not activated in the current shell.

Common situations: Fresh machines without gh installed; running goose from a desktop app or systemd service with a minimal PATH; container images missing the gh package; forgetting to `source bin/activate-hermit` in the goose repo.

Related errors


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