nikivdev/code · error
ai not found in PATH
Error message
ai not found in PATH
What it means
This error is raised by `run_fix_f_commit_ai` when the external `ai` CLI executable cannot be located on PATH via `which::which("ai")`. The library depends on this external tool to perform AI-assisted secret redaction and aborts the fix flow early with a clear message rather than failing mid-execution.
Source
Thrown at src/commit.rs:475
let agent_name =
env::var("FLOW_FIX_COMMIT_AGENT").unwrap_or_else(|_| "fix-f-commit".to_string());
let handoff_enabled = agent_name.trim().to_lowercase() != "off";
let ai_available = which::which("ai").is_ok();
if !handoff_enabled && !ai_available {
return Ok(false);
}
git_run(&["add", "."])?;
ensure_no_internal_staged(repo_root)?;
ensure_no_unwanted_staged(repo_root)?;
gitignore_policy::enforce_staged_policy(repo_root)?;
Ok(!scan_diff_for_secrets(repo_root).is_empty())
}
fn run_fix_f_commit_ai(repo_root: &Path, task: &str) -> Result<()> {
if which::which("ai").is_err() {
bail!("ai not found in PATH");
}
let status = Command::new("ai")
.args(["--prompt", task])
.current_dir(repo_root)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.context("failed to run ai")?;
if !status.success() {
bail!("ai auto-fix failed");
}
Ok(())
}
View on GitHub (pinned to a747e741ae)
Solutions
- Install the `ai` CLI (e.g. via your package manager or its official installer).
- Ensure its install directory is on PATH: `export PATH="$HOME/.local/bin:$PATH"` and verify with `which ai`.
- If you do not want AI fixing, set `FLOW_FIX_COMMIT_AGENT=off` and fix the findings manually instead.
- Run the commit flow from a shell where `which ai` succeeds.
Example fix
// before: command not found // $ flow commit ... // Error: ai not found in PATH // after export PATH="$HOME/.local/bin:$PATH" which ai # /home/user/.local/bin/ai
Defensive patterns
Strategy: fallback
Validate before calling
// check availability before entering the AI fix path
if which::which("ai").is_err() {
eprintln!("ai CLI missing; fix findings manually or install it");
std::process::exit(1);
} Try / catch
match run_fix_f_commit_ai(repo_root, task) {
Err(e) if e.to_string().contains("ai not found in PATH") => {
// fallback: remediate manually instead of the AI path
eprintln!("falling back to manual redaction of findings");
}
Err(e) => return Err(e),
Ok(_) => {}
} Prevention
- Install the ai CLI and verify with `which ai` before scripted commits
- Add its install dir (~/.local/bin, ~/.cargo/bin) to PATH in shell profiles and CI
- Use FLOW_FIX_COMMIT_AGENT=off as a supported fallback when the CLI is unavailable
- Prefer explicit `git add <file>` in automation to avoid entering the interactive fix path
When it happens
Trigger: `warn_secrets_in_diff` selects the AI fix path (interactive TTY, FLOW_FIX_COMMIT_AGENT enabled) and calls `run_fix_f_commit_ai`, but the `ai` binary is not installed or not on the PATH of the current process.
Common situations: AI CLI never installed; installed in a user-local bin dir (e.g. ~/.local/bin, ~/.cargo/bin) missing from PATH; running the commit tool from an IDE terminal, cron, or CI where PATH differs from the interactive shell; the tool named differently after a version change.
Related errors
- fzf not found – install it for fuzzy selection
- lin is not on PATH. Build/install from this repo (scripts/de
- flox is not installed. Install it from https://flox.dev/docs
- direnv is not on PATH. Install it from https://direnv.net/#i
- No env vars found
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/22f50b045d94ff52.
Report an issue: GitHub.