{"record":{"id":"fb1d539d664da24e","repo":"nikivdev/code","slug":"jj-failed-fb1d53","errorCode":null,"errorMessage":"jj {} failed","messagePattern":"jj (.+?) failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ext.rs","lineNumber":381,"sourceCode":"fn jj_run_in(repo_root: &Path, args: &[&str]) -> Result<()> {\n    let output = Command::new(\"jj\")\n        .current_dir(repo_root)\n        .args(args)\n        .output()\n        .with_context(|| format!(\"failed to run jj {}\", args.join(\" \")))?;\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    if !stdout.trim().is_empty() {\n        print!(\"{}\", stdout);\n    }\n    let stderr = String::from_utf8_lossy(&output.stderr);\n    for line in stderr.lines() {\n        if line.contains(\"Refused to snapshot\") {\n            continue;\n        }\n        eprintln!(\"{}\", line);\n    }\n    if !output.status.success() {\n        bail!(\"jj {} failed\", args.join(\" \"));\n    }\n    Ok(())\n}\n\nfn jj_capture_in(repo_root: &Path, args: &[&str]) -> Result<String> {\n    let output = Command::new(\"jj\")\n        .current_dir(repo_root)\n        .args(args)\n        .output()\n        .with_context(|| format!(\"failed to run jj {}\", args.join(\" \")))?;\n    if !output.status.success() {\n        bail!(\"jj {} failed\", args.join(\" \"));\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\n}\n\nfn git_capture_in(repo_root: &Path, args: &[&str]) -> Result<String> {\n    let output = Command::new(\"git\")","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ext.rs#L363-L399","documentation":"jj_run_in executes a jj subcommand in the repo root, streaming its stderr; if the process exits non-zero it bails with the full argument list. The actual jj error text is already printed to stderr lines above the bail message.","triggerScenarios":"Any jj invocation from prepare_source_workspace failing: workspace add refused, snapshot refused due to a dirty/locked working copy, invalid args, or jj missing/crashing.","commonSituations":"Source repo with conflicts or an inconsistent working copy; incompatible jj version; running while another jj process holds a lock.","solutions":["Read the stderr lines printed just before the error to see jj's own message, then fix that condition.","Re-run the same jj command manually in the source repo to reproduce and diagnose.","Resolve working-copy problems (conflicts, locks) in the source workspace and retry the import."],"exampleFix":"// before: opaque failure\n// error: jj workspace add ... failed\n// after (shell): reproduce for the real error\ncd <source> && jj workspace add --help  # or re-run the failing command verbatim","handlingStrategy":"retry","validationCode":"let probe = std::process::Command::new(\"jj\")\n    .args([\"--version\"])\n    .output()\n    .map(|o| o.status.success())\n    .unwrap_or(false);\nif !probe { return Err(anyhow!(\"jj is unavailable; install jujutsu first\")); }","typeGuard":null,"tryCatchPattern":"for attempt in 0..2 {\n    match import_external_path(source) {\n        Err(e) if e.to_string().starts_with(\"jj \") && attempt == 0 => {\n            eprintln!(\"jj failed ({e}); inspect stderr above, fixing state and retrying\");\n            continue;\n        }\n        r => { r?; break; }\n    }\n}","preventionTips":["Pin a compatible jj version in your environment.","Avoid running concurrent jj operations on the same workspace.","Always read the stderr lines the tool prints before the bail message."],"tags":["vcs","subprocess","jj"],"backgroundTag":"external-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}