GitoxideLabs/gitoxide · error

JSON output isn't supported

Error message

JSON output isn't supported

What it means

Guard clause in the `env` command handler of gitoxide-core. The CLI `ein tool env` command only implements human-readable rendering of the resolved git environment; when the caller passes `--format json` (OutputFormat not Human), the function aborts via anyhow::bail! instead of silently emitting human output. It fires whenever a user or script requests JSON serialization of environment output, which has no serializer implemented. Fix is either to implement a JSON serializer for the env output or accept the limitation and use the default human format.

Solutions

  1. Use the default human output format for the env command
  2. Drop the `--format json` flag from the command line
  3. If machine-readable output is needed, parse the human output or add JSON support upstream

Example fix

// before
gix env --format json
// after
gix env
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(e) = gix_core::env(&mut out, format) {
    if format != OutputFormat::Human {
        gix_core::env(&mut out, OutputFormat::Human)?;
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: Calling `gix_core::env(out, OutputFormat::Json)` or running the corresponding CLI command with `--format json`.

Common situations: Scripts that uniformly pass a JSON format flag to all gix subcommands; assuming feature parity of output formats across commands.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/013d48ceebe988f7. Report an issue: GitHub.

Appendix: source

Thrown at gitoxide-core/src/lib.rs:102

mod output;

mod discover;
pub use discover::discover;

pub fn trust(paths: &[std::path::PathBuf], mut out: impl std::io::Write) -> anyhow::Result<()> {
    let trust_width = "Reduced".len();
    for path in paths {
        let trust = gix::sec::Trust::from_path_ownership(path)?;
        let trust = format!("{trust:?}");
        writeln!(out, "{trust:<trust_width$} {}", path.display())?;
    }
    Ok(())
}

pub fn env(mut out: impl std::io::Write, format: OutputFormat) -> anyhow::Result<()> {
    if format != OutputFormat::Human {
        bail!("JSON output isn't supported");
    }

    let width = 15;
    writeln!(
        out,
        "{field:>width$}: {}",
        std::path::Path::new(gix::path::env::shell()).display(),
        field = "shell",
    )?;
    writeln!(
        out,
        "{field:>width$}: {:?}",
        gix::path::env::installation_config_prefix(),
        field = "config prefix",
    )?;
    writeln!(
        out,
        "{field:>width$}: {:?}",

View on GitHub (pinned to e73179060b)