jdx/mise · error
cannot check staged changes in
Error message
cannot check staged changes in {}: {} What it means
staged_paths runs `git diff --name-only --cached --` (with GIT_OPTIONAL_LOCKS=0) inside each relevant root to enumerate staged changes. If that git invocation exits non-zero, mise bails with this error including the root path and git's trimmed stderr. It surfaces underlying git failures (corrupt repo, permission problems, dubious ownership) that would otherwise be hidden.
Solutions
- Read the embedded git stderr in the message and fix that specific git error.
- For 'dubious ownership' errors, run `git config --global --add safe.directory <root>` for the reported path.
- Repair or remove the broken .git directory in the affected root, then retry the sync.
- Check permissions on the directory and ensure the user running mise can execute git there.
Example fix
// before $ mise dot sync error: cannot check staged changes in ~/.config: fatal: detected dubious ownership in repository at '/home/user/.config' // after $ git config --global --add safe.directory /home/user/.config $ mise dot sync
Defensive patterns
Strategy: try-catch
Validate before calling
# pre-flight the exact git call mise makes git -C "$ROOT" diff --name-only --cached -- >/dev/null || echo "git fails in $ROOT: $?"
Try / catch
match run_sync() {
Err(e) if e.starts_with("cannot check staged changes in") => {
// parse embedded git stderr, fix repo (safe.directory, permissions), retry
}
other => other,
} Prevention
- Add safe.directory entries for cross-user dotfiles roots.
- Keep work roots as valid git repositories (don't half-delete .git).
- Verify git works in each sync root before automating syncs.
When it happens
Trigger: During `mise dot sync` pull, the per-root `git diff --cached` subprocess returns a non-zero status; the git stderr text is embedded in the message. Common causes: the directory is a broken/partial git repo, `safe.directory` dubious-ownership refusal, or filesystem permission errors running git.
Common situations: A dotfiles directory that was copied from another user/machine triggering git's 'dubious ownership' check; a corrupted .git directory in the work root; read-only mounts that prevent git from running.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- cannot check staged changes: git is unavailable
- cannot replace local history while
- changed after permission planning; retry pull
- changed during application; left untouched
- could not reuse the fetched setup preview
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/9b2cb46d243e0d3d.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/history/sync/apply.rs:1025
.arg("-C")
.arg(&root)
.args([
"-c",
"core.fsmonitor=false",
"diff",
"--cached",
"--name-only",
"-z",
"--no-renames",
"--no-ext-diff",
"--no-textconv",
"--",
])
.env("GIT_OPTIONAL_LOCKS", "0")
.stdin(std::process::Stdio::null())
.output()?;
if !output.status.success() {
bail!(
"cannot check staged changes in {}: {}",
display_path(&root),
String::from_utf8_lossy(&output.stderr).trim()
);
}
for name in output
.stdout
.split(|byte| *byte == 0)
.filter(|name| !name.is_empty())
{
#[cfg(unix)]
let relative = {
use std::os::unix::ffi::OsStrExt;
PathBuf::from(std::ffi::OsStr::from_bytes(name))
};
#[cfg(not(unix))]
let relative = PathBuf::from(std::str::from_utf8(name)?);
staged.insert(normalize_target(&root.join(relative)));View on GitHub (pinned to 533346cc37)