nikivdev/code · error · anyhow::Error

direnv is not on PATH. Install it from https://direnv.net/#i

Error message

direnv is not on PATH. Install it from https://direnv.net/#installation and rerun `flow doctor`.

What it means

flow doctor requires direnv for environment loading. ensure_direnv_on_path checks `which direnv`; before failing it attempts an automatic install via zerobrew. If that install fails or does not put direnv on PATH, it bails with the official install link.

Source

Thrown at src/doctor.rs:116

    vcs::ensure_jj_installed()?;
    println!("✅ jj found on PATH");
    Ok(())
}

fn ensure_direnv_on_path(zerobrew_available: bool) -> Result<()> {
    match which::which("direnv") {
        Ok(path) => {
            println!("✅ direnv found at {}", path.display());
            Ok(())
        }
        Err(_) => {
            if maybe_install_with_zerobrew(zerobrew_available, "direnv", "direnv")? {
                if let Ok(path) = which::which("direnv") {
                    println!("✅ direnv installed via zerobrew at {}", path.display());
                    return Ok(());
                }
            }
            bail!(
                "direnv is not on PATH. Install it from https://direnv.net/#installation and rerun `flow doctor`."
            )
        }
    }
}

fn find_bundled_lin() -> Option<PathBuf> {
    let exe_dir = std::env::current_exe()
        .ok()
        .and_then(|p| p.parent().map(PathBuf::from))?;
    let candidate = exe_dir.join("lin");
    if candidate.exists() {
        Some(candidate)
    } else {
        None
    }
}

View on GitHub (pinned to a747e741ae)

Solutions

  1. Install direnv per https://direnv.net/#installation and rerun `flow doctor`
  2. Install zerobrew first so the doctor's automatic direnv install can run
  3. Add direnv's install location to your PATH
Defensive patterns

Strategy: validation

Validate before calling

if which::which("direnv").is_err() {
    eprintln!("direnv missing; install from https://direnv.net/#installation");
}

Prevention

When it happens

Trigger: Running `flow doctor` when direnv is not on PATH and the zerobrew auto-install either was skipped (zerobrew unavailable), reported failure, or installed to a directory not on PATH.

Common situations: Fresh machine setup, zerobrew not installed so auto-install cannot happen, or direnv installed via an unsupported package manager to a non-PATH location.

Related errors


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