{"record":{"id":"fda344b9d4ca944c","repo":"rust-lang/cargo","slug":"git-is-not-available-help-to-still-use-git-fo","errorCode":null,"errorMessage":"`git` is not available\nhelp: to still use `git` for fetching, please install it\nhelp: to use Cargo's native git support, re-try with `net.git-fetch-with-cli = false`\nhttps://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli","messagePattern":"`git` is not available\nhelp: to still use `git` for fetching, please install it\nhelp: to use Cargo's native git support, re-try with `net\\.git-fetch-with-cli = false`\nhttps://doc\\.rust-lang\\.org/cargo/reference/config\\.html#netgit-fetch-with-cli","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/git/utils.rs","lineNumber":1255,"sourceCode":"/// hatch for users that would prefer to use `git`-the-CLI for fetching\n/// repositories instead of `libgit2`-the-library. This should make more\n/// flavors of authentication possible while also still giving us all the\n/// speed and portability of using `libgit2`.\n///\n/// [1]: https://doc.rust-lang.org/nightly/cargo/reference/config.html#netgit-fetch-with-cli\n#[tracing::instrument(skip(repo, gctx))]\nfn fetch_with_cli(\n    repo: &git2::Repository,\n    url: &str,\n    refspecs: &[String],\n    tags: bool,\n    shallow: gix::remote::fetch::Shallow,\n    gctx: &GlobalContext,\n) -> CargoResult<()> {\n    debug!(target: \"git-fetch\", backend = \"git-cli\");\n\n    let Some(git_version) = git_version() else {\n        anyhow::bail!(\n            \"`git` is not available\nhelp: to still use `git` for fetching, please install it\nhelp: to use Cargo's native git support, re-try with `net.git-fetch-with-cli = false`\nhttps://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli\"\n        );\n    };\n\n    let mut cmd = ProcessBuilder::new(\"git\");\n    // Avoid potential for unused work that may also hang (#15775)\n    cmd.arg(\"-c\").arg(\"core.fsmonitor=false\");\n    // Avoid warnings with `--no-show-forced-updates`\n    cmd.arg(\"-c\").arg(\"advice.fetchShowForcedUpdates=false\");\n    // Have 429's retried in git, where supported\n    let max_retries = gctx\n        .net_config()?\n        .retry\n        .unwrap_or(network::retry::MAX_RETRY_DEFAULT);\n    cmd.arg(\"-c\").arg(format!(\"http.maxRetries={max_retries}\"));","sourceCodeStart":1237,"sourceCodeEnd":1273,"githubUrl":"https://github.com/rust-lang/cargo/blob/42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9/src/sources/git/utils.rs#L1237-L1273","documentation":"In `fetch_with_cli` (called by `fetch`), Cargo is configured to shell out to the `git` CLI for fetching (`net.git-fetch-with-cli = true`), but `git_version()` returned None because no usable `git` executable was found on PATH. Cargo aborts the fetch with guidance to install git or fall back to its native (gitoxide/libgit2) fetch support.","triggerScenarios":"Running cargo fetch/build/update with `net.git-fetch-with-cli = true` in .cargo/config.toml (or CARGO_NET_GIT_FETCH_WITH_CLI=true) while the `git` binary is absent from PATH or not executable.","commonSituations":"CI containers/minimal Docker images without git installed; Windows machines without Git for Windows in PATH; restricted sandboxes where git was removed; typo'd PATH in CI environment.","solutions":["Install git (apt-get install git / choco install git / brew install git) or add its bin directory to PATH.","Set `net.git-fetch-with-cli = false` in .cargo/config.toml (or unset CARGO_NET_GIT_FETCH_WITH_CLI) to use Cargo's native git support.","Verify with `git --version` in the same shell/CI job that cargo runs in.","If git is intentionally unavailable, vendor dependencies (`cargo vendor`) to avoid network git fetches."],"exampleFix":"// before (.cargo/config.toml)\n[net]\ngit-fetch-with-cli = true\n// after: either install git, or switch back to native fetch\n[net]\ngit-fetch-with-cli = false","handlingStrategy":"validation","validationCode":"let have_git = std::process::Command::new(\"git\").arg(\"--version\").output().is_ok();\nassert!(have_git, \"git must be on PATH when net.git-fetch-with-cli = true\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install git as a base-layer step in all CI/Docker images that run cargo.","Only enable net.git-fetch-with-cli when private-registry auth actually requires it.","Prefer `cargo vendor` or a sparse registry for hermetic builds with no git dependency.","Run `git --version` as an early CI sanity check."],"tags":["git","missing-dependency","network","cargo-config"],"backgroundTag":"missing-dependency","analyzedSha":"42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9","analyzedAt":"2026-09-08T04:50:20.151Z","contentChangedAt":"2026-09-08T04:50:20.151Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}