zed-industries/zed · error

Could not find gdb path or it's not installed

Error message

Could not find gdb path or it's not installed

What it means

gdb adapter resolution: Zed first tries the user-configured binary path (kept only if it exists on disk) and in parallel runs which('gdb'). If which() fails and no valid user path exists, this bail fires - neither an explicit path nor a discoverable gdb on PATH. The which() failure itself was already wrapped with context 'Could not find gdb in path'; this is the combined verdict.

Source

Thrown at crates/dap_adapters/src/gdb.rs:208

            .and_then(|v| v.as_str())
            .map(|s| s.to_string());

        let gdb_path = if let Some(path) = gdb_path_from_config {
            path
        } else {
            // Original logic: use user_installed_path or search in system path
            let user_setting_path = user_installed_path
                .filter(|p| p.exists())
                .and_then(|p| p.to_str().map(|s| s.to_string()));

            let gdb_path_result = delegate
                .which(OsStr::new("gdb"))
                .await
                .and_then(|p| p.to_str().map(|s| s.to_string()))
                .context("Could not find gdb in path");

            if gdb_path_result.is_err() && user_setting_path.is_none() {
                bail!("Could not find gdb path or it's not installed");
            }

            user_setting_path.unwrap_or_else(|| gdb_path_result.unwrap())
        };

        // Arguments: use gdb_args from config if present, else user_args, else default
        let gdb_args = {
            let args = config
                .config
                .get("gdb_args")
                .and_then(|v| v.as_array())
                .map(|arr| {
                    arr.iter()
                        .filter_map(|v| v.as_str().map(|s| s.to_string()))
                        .collect::<Vec<_>>()
                })
                .or(user_args.clone())
                .unwrap_or_else(|| vec!["-i=dap".into()]);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Install gdb (apt install gdb / brew install gdb) and ensure it is on PATH
  2. Set the adapter's user binary path to the absolute gdb location (verify with `which gdb`)
  3. For containers/remote environments, install gdb inside the same environment Zed's adapter runs in
  4. On macOS, codesign gdb after install if signing errors follow

Example fix

// before: relies on PATH
"debug": { "adapters": { "lldb": { "binary": { "path": "/no/such/gdb" } } } }

// after: verify existence before starting a session
let gdb = which::which("gdb").or_else(|_| {
    let p = std::path::PathBuf::from("/opt/homebrew/bin/gdb");
    if p.exists() { Ok(p) } else { Err(anyhow::anyhow!("gdb not found")) }
})?;
Defensive patterns

Strategy: validation

Validate before calling

// Resolve gdb up front with a clear failure instead of at session start
let gdb_path = user_installed_path
    .filter(|p| p.exists())
    .or_else(|| which::which("gdb").ok())
    .with_context(|| "gdb not found: install it or set an absolute path in the adapter config")?;

Type guard

fn gdb_available(configured: Option<&std::path::Path>) -> bool {
    configured.map(|p| p.exists()).unwrap_or_else(|| which::which("gdb").is_ok())
}

Prevention

When it happens

Trigger: Starting a gdb debug session when gdb is not installed, is installed but not on PATH (non-login shells, snap/flatpak wrappers), or the user setting's path points to a nonexistent location. Note the user path is filtered by p.exists(), so a stale configured path silently falls back to PATH lookup.

Common situations: Fresh machines without build tools; gdb installed via Homebrew but PATH not updated (especially /opt/homebrew/bin on Apple Silicon); remote/container dev environments lacking gdb; typo'd absolute path in settings; gdb present only inside a container while Zed runs on the host.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/87bc9ad391b5bfc7. Report an issue: GitHub.