gitbutlerapp/gitbutler · warning

command not found

Error message

command not found

What it means

The TUI command mode executes the typed command as a child process. When `Command::spawn()` fails with `std::io::ErrorKind::NotFound`, the binary is not on `PATH`; the code converts this OS error into a user-facing transient error instead of crashing the TUI.

Solutions

  1. check the command spelling and install the missing binary
  2. use the absolute path to the executable in the command
  3. verify with `echo $PATH` (via the TUI shell) that the tool's directory is on `PATH`

Example fix

// before
> rg pattern        # rg not installed
// after
> /usr/bin/grep pattern   # or install ripgrep first
Defensive patterns

Strategy: try-catch

Validate before calling

for cmd in candidate_paths { if Path::new(cmd).exists() { return Some(cmd); } } // resolve absolute path before spawning

Try / catch

match run_tui_command(input) {
    Err(e) | Transient(e) if e.to_string().contains("command not found") => {
        eprintln!("'{input}' not on PATH; install it or use an absolute path.");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Typing a shell command in the TUI's command mode that references an executable not installed or not on the current `PATH` (note the TUI may have a different `PATH` than your interactive shell).

Common situations: Typos in the command name, invoking tools installed via a shell profile not loaded in the TUI's environment (nvm/rvm/pyenv shims), or running the TUI from a systemd/CI environment with a minimal `PATH`.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/a0244ae7061b2799. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/legacy/status/tui/app/command_mode.rs:223

                        return Ok(());
                    }
                };
                let Some(binary) = args.next() else {
                    return Ok(());
                };
                let mut cmd = Command::new(binary);
                cmd.args(args);
                cmd
            }
        };

        cmd.current_dir(ctx.workdir_or_fail()?);

        let mut child = match cmd.spawn() {
            Ok(child) => child,
            Err(err) => {
                if err.kind() == std::io::ErrorKind::NotFound {
                    self.push_transient_error(anyhow!("command not found"));
                    return Ok(());
                } else {
                    return Err(err).context("failed to start command");
                }
            }
        };
        let status = child.wait()?;

        if !IN_TEST {
            out.prompt_single_line("\npress enter to continue...")?;
        }

        if status.success() {
            messages.extend([
                Message::EnterNormalModeAfterConfirmingOperation,
                Message::Reload(None, ReloadCause::Mutation),
            ]);
        } else {

View on GitHub (pinned to 58e5313667)