nikivdev/code · error

{} {} failed: {}

Error message

{} {} failed: {}

What it means

Raised by jj_run_output_in in src/sync.rs when a jj command fails. It extracts the first non-empty trimmed line from stderr (falling back to stdout), or the literal "jj command failed", and formats it as `<jj_bin> <args> failed: <concise>`. This gives a single-line actionable summary of a jj invocation failure.

Source

Thrown at src/sync.rs:4699

}

fn jj_run_preferred_in(repo_root: &Path, args: &[&str]) -> Result<()> {
    let jj_bin = jj_preferred_binary();
    let output = Command::new(&jj_bin)
        .current_dir(repo_root)
        .args(args)
        .output()
        .with_context(|| format!("failed to run {} {}", jj_bin.display(), args.join(" ")))?;
    if !output.status.success() {
        let stderr = String::from_utf8_lossy(&output.stderr);
        let stdout = String::from_utf8_lossy(&output.stdout);
        let concise = stderr
            .lines()
            .chain(stdout.lines())
            .map(str::trim)
            .find(|line| !line.is_empty())
            .unwrap_or("jj command failed");
        bail!(
            "{} {} failed: {}",
            jj_bin.display(),
            args.join(" "),
            concise
        );
    }
    Ok(())
}

fn jj_bookmark_exists(repo_root: &Path, name: &str) -> bool {
    let output = jj_capture_in(repo_root, &["bookmark", "list"]).unwrap_or_default();
    output
        .lines()
        .any(|line| line.trim_start().starts_with(name))
}

fn jj_bookmark_create_or_set(repo_root: &Path, name: &str, rev: &str) -> Result<()> {
    if jj_bookmark_exists(repo_root, name) {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Read the `concise` line to identify the exact jj error
  2. Run the failing command manually (`<jj_bin> <args>`) to see complete output
  3. Resolve the underlying issue (fix revision, authenticate, resolve conflicts) and retry
  4. Ensure FLOW_JJ_BIN resolves to a working jj binary
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity-check jj can read the repo before heavy sync operations
let out = std::process::Command::new(jj_bin()).args(["st"]).output()?;
if !out.status.success() {
    eprintln!("jj st failed: {}", String::from_utf8_lossy(&out.stderr));
}

Try / catch

match sync_result {
    Err(e) if e.to_string().contains("failed:") && e.to_string().contains("jj") => {
        // concise stderr line is embedded after the second ': '
        eprintln!("{e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: A jj command run through jj_run_output_in exits non-zero and the caller formats the failure with jj_bin.display(), the joined args, and the first non-empty stderr/stdout line.

Common situations: jj rejects an operation due to repo conflicts, missing remote, bad revision names, or auth failures; environment binary issues surfaced through stderr.

Related errors


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