vercel/turborepo · critical
which git produced an invalid absolute path {}
Error message
which git produced an invalid absolute path {} What it means
Scm::find_bin() locates the git executable with the which crate and converts the discovered path into an AbsoluteSystemPathBuf. which guarantees an absolute path, so the conversion can only fail on non-UTF-8 bytes — the panic fires when the resolved git binary lives under a path containing invalid UTF-8.
Source
Thrown at crates/turborepo-scm/src/lib.rs:315
// If which produces an invalid absolute path, it's not an execution error, it's
// a programming error. We expect it to always give us an absolute path
// if it gives us any path. If that's not the case, we should crash.
let bin = Self::find_bin()?;
let root =
find_git_root(path_in_repo).map_err(|e| GitError::Root(path_in_repo.to_owned(), e))?;
Ok(Self {
root,
bin,
attrs: OnceLock::new(),
github_actions_remote_base_ref_fallback: false,
slowest_files: None,
})
}
pub fn find_bin() -> Result<AbsoluteSystemPathBuf, which::Error> {
which::which("git").map(|path| {
AbsoluteSystemPathBuf::try_from(path.as_path()).unwrap_or_else(|_| {
panic!(
"which git produced an invalid absolute path {}",
path.display()
)
})
})
}
}
fn find_git_root(turbo_root: &AbsoluteSystemPath) -> Result<AbsoluteSystemPathBuf, Error> {
let rev_parse = Command::new("git")
.args(["rev-parse", "--show-cdup"])
.current_dir(turbo_root)
.output()?;
if !rev_parse.status.success() {
let stderr = String::from_utf8_lossy(&rev_parse.stderr);
return Err(Error::git_error(format!(
"git rev-parse --show-cdup error: {stderr}"
)));View on GitHub (pinned to 7fe373bc27)
Solutions
- Check what actually resolves: `where git` (Windows) or `which git` — the printed path should be plain ASCII
- Reinstall git to a default ASCII location (e.g. C:\Program Files\Git) and make sure that PATH entry wins
- Fix or remove the non-UTF-8 PATH entry (often caused by an encoded username — recreate the directory in ASCII)
- As a workaround, set PATH explicitly in the shell/task before running turbo
Defensive patterns
Strategy: validation
Validate before calling
// Resolve git once and verify the path is ASCII/UTF-8 before turbo runs
use std::process::Command;
let out = Command::new("where") // Windows; use "which -a" on Unix
.arg("git")
.output()?;
let paths = String::from_utf8_lossy(&out.stdout);
if paths.contains('\uFFFD') {
return Err("git resolved to a non-UTF-8 path — fix PATH".into());
} Prevention
- Install git in a default ASCII-only location and put that PATH entry first
- Avoid non-ASCII/legacy-encoded usernames and directories in PATH on Windows
- In CI images, set PATH explicitly to known-ASCII tool directories before running turbo
When it happens
Trigger: A PATH entry with non-UTF-8 bytes (legacy ANSI-encoded directory or username) that resolves git first; a git shim/wrapper installed in an oddly-encoded location on Windows.
Common situations: Windows user profiles with non-ASCII or legacy-encoded names where the PATH byte sequence is not valid UTF-8; corporate wrapper scripts in unusual directories; WOS/WSL boundary quirks mixing encodings.
Related errors
- joined path is absolute and valid utf8: {err:?}
- clean should produce valid UTF-8: {err:?}
- anchored system path is relative: {}
- clean should preserve utf8: {err:?}
- path cleaning should preserve UTF-8: {err:?}
AI-assisted analysis of vercel/turborepo@7fe373bc27 (2026-08-17).
Data as JSON: /api/errors/9c42c97bef214845.
Report an issue: GitHub.