{"record":{"id":"e08dca14926ab6a7","repo":"jdx/mise","slug":"failed-to-locate-git-repository-for","errorCode":null,"errorMessage":"failed to locate Git repository for {}: {}","messagePattern":"failed to locate Git repository for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2141,"sourceCode":"    let mut root_command = Command::new(\"git\");\n    root_command\n        .arg(\"-C\")\n        .arg(source)\n        .args([\"-c\", \"safe.directory=*\", \"rev-parse\", \"--show-toplevel\"])\n        .stdout(std::process::Stdio::piped())\n        .stderr(std::process::Stdio::piped());\n    crate::git::sanitize_git_command(&mut root_command);\n    let root_output = root_command.output().wrap_err_with(|| {\n        format!(\n            \"failed to locate Git repository for {}\",\n            source.display_user()\n        )\n    })?;\n    if !root_output.status.success() {\n        let stderr = String::from_utf8_lossy(&root_output.stderr)\n            .trim()\n            .to_string();\n        bail!(\n            \"failed to locate Git repository for {}: {}\",\n            source.display_user(),\n            if stderr.is_empty() {\n                root_output.status.to_string()\n            } else {\n                stderr\n            }\n        );\n    }\n    let root = root_output\n        .stdout\n        .strip_suffix(b\"\\n\")\n        .unwrap_or(&root_output.stdout);\n    let root = root.strip_suffix(b\"\\r\").unwrap_or(root);\n    let safe = format!(\"safe.directory={}\", path_buf_from_git_bytes(root).display());\n    let mut command = Command::new(\"git\");\n    command\n        .arg(\"-C\")","sourceCodeStart":2123,"sourceCodeEnd":2159,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2123-L2159","documentation":"When resolving a dotfile source that lives inside a Git repository, mise runs `git rev-parse --show-toplevel` (or similar) in the source directory. If the command cannot be run or the repo root cannot be located, it bails with this message including the target source path and git's stderr (or the exit status when stderr is empty).","triggerScenarios":"A tracked/git-managed dotfile source points inside a directory that is not a Git work tree, or the `git` binary is unavailable/fails, during source resolution for a track-mode or git-aware entry.","commonSituations":"Dotfiles directory not yet cloned on a new machine; the source path was moved outside the repo; `git` not installed or not on PATH; a corrupted .git directory.","solutions":["Clone or restore the dotfiles Git repository so the source is inside a valid work tree.","Install or repair `git` and ensure it is on PATH.","Update the entry's `source` to a path inside the actual repository."],"exampleFix":"# before: source deleted\ndotfiles/  # missing\n# after\ngit clone git@github.com:user/dotfiles.git ~/dotfiles  # entry source = ~/dotfiles/...","handlingStrategy":"validation","validationCode":"let out = std::process::Command::new(\"git\")\n    .args([\"rev-parse\", \"--show-toplevel\"])\n    .current_dir(source)\n    .output()?;\nif !out.status.success() {\n    return Err(\"source is not inside a Git repository or git is unavailable\".into());\n}","typeGuard":null,"tryCatchPattern":"match dotfiles_apply() {\n    Err(e) if e.to_string().contains(\"failed to locate Git repository\") => {\n        eprintln!(\"clone the dotfiles repo or install git: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Clone the dotfiles repo before enabling git-backed entries.","Ensure `git` is installed and on PATH in minimal containers/CI.","Keep .git intact — don't copy sources out of the repo."],"tags":["dotfiles","git","filesystem","mise"],"backgroundTag":"git-command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}