nikivdev/code · error

jj is required but not available on PATH

Error message

jj is required but not available on PATH

What it means

ensure_jj_installed verifies that the jj (Jujutsu) VCS binary is usable by running `jj --version`. If the command exits with a non-zero status (typically because jj is not installed or not on PATH), it bails with this error. It is thrown before any jj repository operations are attempted so callers fail fast with a clear message.

Source

Thrown at src/vcs.rs:14

use std::path::{Path, PathBuf};
use std::process::Command;

use anyhow::{Context, Result, bail};

pub fn ensure_jj_installed() -> Result<()> {
    let status = Command::new("jj")
        .arg("--version")
        .stdout(std::process::Stdio::null())
        .stderr(std::process::Stdio::null())
        .status()
        .context("failed to run jj --version")?;
    if !status.success() {
        bail!("jj is required but not available on PATH");
    }
    Ok(())
}

pub fn ensure_jj_repo() -> Result<PathBuf> {
    let cwd = std::env::current_dir().context("failed to read current directory")?;
    ensure_jj_repo_in(&cwd)
}

pub fn ensure_jj_repo_in(path: &Path) -> Result<PathBuf> {
    ensure_jj_installed()?;
    if let Ok(root) = try_jj_root(path) {
        return Ok(root);
    }

    let git_dir = path.join(".git");
    if git_dir.exists() {
        let status = Command::new("jj")

View on GitHub (pinned to a747e741ae)

Solutions

  1. Install Jujutsu (e.g. `cargo install jj-cli`, `brew install jj`, or your distro package) and confirm `jj --version` works in a terminal.
  2. Fix PATH for the environment running this code: add jj's install bin dir to PATH in the shell profile, service unit, or CI environment.
  3. Verify the binary is executable (`chmod +x $(which jj)`) or reinstall it if `jj --version` fails despite being found.
  4. If jj is installed in a known non-PATH location, prepend that directory to PATH programmatically before calling the library.

Example fix

// before (CI job without jj)
- run: ./mytool sync   # panics: jj is required but not available on PATH
// after
- run: cargo install jj-cli
- run: jj --version
- run: ./mytool sync
Defensive patterns

Strategy: validation

Validate before calling

use std::process::Command;
fn jj_available() -> bool {
    Command::new("jj")
        .arg("--version")
        .stdout(std::process::Stdio::null())
        .stderr(std::process::Stdio::null())
        .status()
        .map(|s| s.success())
        .unwrap_or(false)
}
if !jj_available() {
    eprintln!("Install jj (cargo install jj-cli) and ensure it is on PATH");
    std::process::exit(1);
}

Prevention

When it happens

Trigger: Calling ensure_jj_installed() (directly or via ensure_jj_repo_in -> ensure_jj_repo) when the `jj` executable is missing from PATH, is not executable, or `jj --version` exits non-zero.

Common situations: Fresh machines or CI containers where Jujutsu was never installed; jj installed via a tool manager (cargo/homebrew) whose bin dir is not on PATH for the current shell or service user; a broken/partial jj installation where the binary exists but fails to run; PATH differences between an interactive shell and a systemd/cron/IDE-spawned process.

Related errors


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