diff --git a/crates/uv-git/src/git.rs b/crates/uv-git/src/git.rs index 86af38a7e..d08cecd95 100644 --- a/crates/uv-git/src/git.rs +++ b/crates/uv-git/src/git.rs @@ -22,8 +22,20 @@ use uv_static::EnvVars; /// checkout is ready to go. See [`GitCheckout::reset`] for why we need this. const CHECKOUT_READY_LOCK: &str = ".ok"; +#[derive(Debug, thiserror::Error)] +pub enum GitError { + #[error("Git executable not found. Ensure that Git is installed and available.")] + GitNotFound, + #[error(transparent)] + Other(#[from] which::Error), +} /// A global cache of the result of `which git`. -pub static GIT: LazyLock> = LazyLock::new(|| which::which("git")); +pub static GIT: LazyLock> = LazyLock::new(|| { + which::which("git").map_err(|e| match e { + which::Error::CannotFindBinaryPath => GitError::GitNotFound, + e => GitError::Other(e), + }) +}); /// A reference to commit or commit-ish. #[derive(