{"id":"b83570a94a75c7ed","repo":"rust-lang/cargo","slug":"no-executable-for-found-in-path","errorCode":null,"errorMessage":"no executable for `{}` found in PATH","messagePattern":"no executable for `(.+?)` found in PATH","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cargo-util/src/paths.rs","lineNumber":142,"sourceCode":"pub fn resolve_executable(exec: &Path) -> Result<PathBuf> {\n    if exec.components().count() == 1 {\n        let paths = env::var_os(\"PATH\").ok_or_else(|| anyhow::format_err!(\"no PATH\"))?;\n        let candidates = env::split_paths(&paths).flat_map(|path| {\n            let candidate = path.join(&exec);\n            let with_exe = if env::consts::EXE_EXTENSION.is_empty() {\n                None\n            } else {\n                Some(candidate.with_extension(env::consts::EXE_EXTENSION))\n            };\n            iter::once(candidate).chain(with_exe)\n        });\n        for candidate in candidates {\n            if candidate.is_file() {\n                return Ok(candidate);\n            }\n        }\n\n        anyhow::bail!(\"no executable for `{}` found in PATH\", exec.display())\n    } else {\n        Ok(exec.into())\n    }\n}\n\n/// Returns metadata for a file (follows symlinks).\n///\n/// Equivalent to [`std::fs::metadata`] with better error messages.\npub fn metadata<P: AsRef<Path>>(path: P) -> Result<Metadata> {\n    let path = path.as_ref();\n    std::fs::metadata(path)\n        .with_context(|| format!(\"failed to load metadata for path `{}`\", path.display()))\n}\n\n/// Returns metadata for a file without following symlinks.\n///\n/// Equivalent to [`std::fs::metadata`] with better error messages.\npub fn symlink_metadata<P: AsRef<Path>>(path: P) -> Result<Metadata> {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/crates/cargo-util/src/paths.rs#L124-L160","documentation":"From resolve_executable (crates/cargo-util/src/paths.rs:124-146). Given a single-component executable name, it walks every directory in $PATH, joins the name (plus the OS exe extension on Windows), and returns the first that is_file(). If none matches, it bails. Cargo uses this to locate external subcommands (cargo-<name>), configured rustc/rustdoc, and helper tools.","triggerScenarios":"Running `cargo <x>` where `cargo-<x>` is not installed or not on PATH; a [build] rustc-wrapper / rustc = path pointing at a bare name that isn't found; a custom runner referenced by name. Also reachable from any library code calling cargo_util::paths::resolve_executable on a missing tool.","commonSituations":"Missing rustfmt, cargo-nextest, sccache, or a project-required cargo-<ext>. A fresh container/CI image without ~/.cargo/bin on PATH. A rustup toolchain switch leaving stale shims. A name typo in config.","solutions":["Install the missing tool: `cargo install cargo-<name>` (or the system package).","Ensure its bin directory is on PATH (e.g. export PATH=\"$HOME/.cargo/bin:$PATH\") and verify with `which cargo-<name>`.","Reference the tool by absolute path instead of a bare name in config.","Check for typos in the command/config value."],"exampleFix":"// before\n$ cargo nextest run\nerror: no executable for `cargo-nextest` found in PATH\n\n// after\n$ cargo install cargo-nextest\n$ cargo nextest run","handlingStrategy":"validation","validationCode":"// Pre-check PATH for an executable before calling resolve_executable\nuse std::env;\n\nfn executable_on_path(name: &str) -> Option<std::path::PathBuf> {\n    let path = env::var_os(\"PATH\")?;\n    for dir in env::split_paths(&path) {\n        let candidate = dir.join(name);\n        let with_ext = if std::env::consts::EXE_EXTENSION.is_empty() {\n            candidate.clone()\n        } else {\n            candidate.with_extension(std::env::consts::EXE_EXTENSION)\n        };\n        if with_ext.is_file() { return Some(with_ext); }\n    }\n    None\n}\n\nif executable_on_path(\"cargo-nextest\").is_none() {\n    eprintln!(\"install cargo-nextest first\");\n}","typeGuard":null,"tryCatchPattern":"match cargo_util::paths::resolve_executable(std::path::Path::new(name)) {\n    Ok(p) => p,\n    Err(e) => {\n        eprintln!(\"tool `{name}` not found on PATH; install it or pass an absolute path\");\n        return Err(e.into());\n    }\n}","preventionTips":["Assert required tools exist in your CI image before invoking cargo.","Prefer absolute paths for configured tools in shared configs.","Keep ~/.cargo/bin on PATH in shells and CI."],"tags":["cargo","path","executable","environment","cargo-util"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}