xai-org/grok-build · error
jj command failed
Error message
jj command failed
What it means
`jj_cli_inner` (behind `jj_cli`/`jj_cli_mut`) runs the Jujutsu (`jj`) CLI in a working directory — with `--ignore-working-copy` for read-only queries — and returns trimmed stdout. On non-zero exit the error message is the trimmed stderr; if jj wrote nothing to stderr this generic fallback "jj command failed" is used. This is the jj counterpart of the git_cli failure path.
Source
Thrown at crates/codegen/xai-grok-workspace/src/session/git.rs:172
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
if output.status.success() {
let stdout = String::from_utf8_lossy(&output.stdout).trim().to_string();
if !stderr.is_empty() {
tracing::warn!(
cwd = %cwd.display(),
"jj_cli success with stderr warnings"
);
}
tracing::debug!(exit_code = 0, stdout_len = stdout.len(), "jj_cli success");
Ok(stdout)
} else {
let code = output.status.code();
tracing::warn!(
cwd = %cwd.display(),
exit_code = ?code,
"jj_cli FAILED"
);
Err(anyhow::anyhow!(
"{}",
if stderr.is_empty() {
"jj command failed"
} else {
&stderr
}
))
}
}
/// Detect the VCS kind for a given path based on the discovered git root.
///
/// Checks for `.jj/` directory alongside `.git/` to identify colocated Jujutsu repos.
pub fn detect_vcs_kind(git_root: &Path) -> VcsKind {
if git_root.join(".jj").is_dir() {
VcsKind::JujutsuColocated
} else {
VcsKind::Git
}View on GitHub (pinned to bc7f02eddd)
Solutions
- Run the same jj command manually in the cwd (`jj -R <cwd> log`) to see the real error.
- Confirm the repo is jj-initialized or colocated (a `.jj/` directory exists) before calling jj commands.
- Upgrade jj (`jj --version`) — older releases may not support `--ignore-working-copy`.
- Run `jj workspace add`/re-init if the workspace metadata is missing or corrupt.
Defensive patterns
Strategy: try-catch
Validate before calling
// Only call jj commands on jj repos, and ensure jj is installed
fn jj_available(cwd: &Path) -> bool {
cwd.join(".jj").is_dir()
&& std::process::Command::new("jj")
.arg("--version")
.output().map(|o| o.status.success()).unwrap_or(false)
} Try / catch
match jj_cli(cwd, &["log", "-r", "@"]).await {
Ok(out) => use_output(out),
Err(e) if e.to_string() == "jj command failed" => {
eprintln!("jj failed in {} with no stderr — run the command manually to see why", cwd.display());
}
Err(e) => eprintln!("jj: {e}"),
} Prevention
- Use `detect_vcs_kind` to route git vs jj instead of calling jj blindly in git-only repos.
- Keep jj up to date — read-only helpers pass `--ignore-working-copy`, absent in old versions.
- Check `.jj/` exists (colocated repo) before issuing jj queries.
- Empty-stderr failures are logged via tracing::warn with cwd and exit code — enable debug logs when diagnosing.
When it happens
Trigger: Any jj invocation via `jj_cli`/`jj_cli_mut` that exits non-zero with empty stderr: no jj repo in cwd, jj version too old to support a flag like `--ignore-working-copy`, corrupted repo, or jj terminated by a signal leaving stderr empty.
Common situations: Calling jj commands in a plain git repo without `.jj/` (not colocated); ancient jj versions lacking `--ignore-working-copy`; workspace operations on repos with unresolved conflicts; jj not on PATH in the spawned environment.
Related errors
- git command failed
- jj workspace add failed: {e}
- git {shown} failed in {}: {}
- no .git file or directory found at {}
- git worktree add failed: {}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/b68baf7df0d61280.
Report an issue: GitHub.