{"record":{"id":"cada209eee53d545","repo":"jdx/mise","slug":"failed-to-list-git-tracked-files-in","errorCode":null,"errorMessage":"failed to list Git-tracked files in {}: {}","messagePattern":"failed to list Git-tracked files in (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":1941,"sourceCode":"        .arg(\"-C\")\n        .arg(source)\n        .arg(\"-c\")\n        .arg(safe)\n        .arg(\"-c\")\n        .arg(\"core.autocrlf=false\")\n        .args([\"ls-files\", \"-z\", \"--cached\", \"--stage\", \"--\", \".\"])\n        .stdout(std::process::Stdio::piped())\n        .stderr(std::process::Stdio::piped());\n    crate::git::sanitize_git_command(&mut command);\n    let output = command.output().wrap_err_with(|| {\n        format!(\n            \"failed to list Git-tracked files in {}\",\n            source.display_user()\n        )\n    })?;\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();\n        bail!(\n            \"failed to list Git-tracked files in {}: {}\",\n            source.display_user(),\n            if stderr.is_empty() {\n                output.status.to_string()\n            } else {\n                stderr\n            }\n        );\n    }\n    output\n        .stdout\n        .split(|byte| *byte == 0)\n        .filter(|record| !record.is_empty())\n        .map(|record| {\n            let tab = record\n                .iter()\n                .position(|byte| *byte == b'\\t')\n                .ok_or_else(|| {","sourceCodeStart":1923,"sourceCodeEnd":1959,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/files.rs#L1923-L1959","documentation":"Thrown when `git ls-files` (or a similar tracked-file listing command) fails for a dotfiles source directory after the repository root was found. Git's stderr, or the exit status if stderr is empty, is included with the source path. The library needs the tracked-file list to enumerate deployable files.","triggerScenarios":"Running a files/apply/unapply plan where `git ls-files` inside the source repository exits non-zero — e.g. corrupt index, detached/broken .git, out-of-memory, or locked index during a concurrent Git operation.","commonSituations":"A concurrent `git rebase`/`git merge` holds an index.lock; the Git index is corrupted; the repo works for rev-parse but the work tree state is broken; antivirus or backup tools lock files on Windows.","solutions":["Inspect the stderr embedded in the message and fix the underlying Git failure (e.g. remove a stale .git/index.lock).","Run `git ls-files` manually in the source to reproduce and diagnose.","Repair or re-clone the repository if its index is corrupted.","Stop concurrent Git processes operating on the same repository."],"exampleFix":"// before\n$ mise files apply\nerror: failed to list Git-tracked files in ~/dotfiles: fatal: Unable to create '.../index.lock': File exists\n\n// after\n$ rm ~/dotfiles/.git/index.lock   # only when no git process is running\n$ mise files apply","handlingStrategy":"retry","validationCode":"use std::process::Command;\nfn ensure_ls_files_ok(source: &std::path::Path) -> anyhow::Result<()> {\n    let out = Command::new(\"git\")\n        .arg(\"ls-files\")\n        .current_dir(source)\n        .output()?;\n    if !out.status.success() {\n        anyhow::bail!(\"git ls-files failed in {}: {}\", source.display(),\n            String::from_utf8_lossy(&out.stderr).trim());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"failed to list Git-tracked files\") => {\n        // check for index.lock, wait, then retry once\n        retry_after(|| run_apply(), std::time::Duration::from_secs(2), 2);\n    }\n    Err(e) => return Err(e),\n    Ok(done) => done,\n}","preventionTips":["Avoid running mise files operations while a git merge/rebase is in progress in the source repo.","Clear stale .git/index.lock only after confirming no git process is running.","Run `git fsck` periodically on the dotfiles repo."],"tags":["git","dotfiles","filesystem"],"backgroundTag":"git-command-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}