jdx/mise · error
{} cannot be recreated as a directory: something else is the
Error message
{} cannot be recreated as a directory: something else is there now; nothing more was changed What it means
Replay records empty directories that must be recreated (restore_dirs). Before mkdir, it verifies the path is not occupied by something else; if a non-directory file or symlink now sits at that path, it aborts to avoid destroying data.
Source
Thrown at src/system/history/replay.rs:690
}
}
});
let pending =
journal::begin_changes("history", &display_path(&step.path), [step.path.clone()])?;
match &step.action {
Action::Write { mode, oid } => write_object(repo, step, mode, oid)?,
Action::Delete => remove(&step.path)?,
_ => unreachable!("filtered to mutating steps"),
}
journal::commit_changes(pending);
touched.push(step.path.clone());
}
for dir in &exec.restore_dirs {
if dir.is_dir() && !dir.is_symlink() {
continue;
}
if dir.exists() || dir.is_symlink() {
bail!(
"{} cannot be recreated as a directory: something else is there now; nothing more was changed",
display_path(dir)
);
}
if let Some(parent) = dir.parent() {
file::create_dir_all(parent)?;
}
let bits = exec.restore_modes.get(&display_path(dir));
let builder = std::fs::DirBuilder::new();
#[cfg(unix)]
let builder = {
let mut builder = builder;
if let Some(bits) = bits {
use std::os::unix::fs::DirBuilderExt;
builder.mode(*bits);
}
builder
};View on GitHub (pinned to afd2eddd3a)
Solutions
- Inspect the path named in the message; move/delete the occupying file or symlink, then re-run
- Re-plan against current state so the restore_dirs list reflects reality
- If the symlink is intentional, exclude that directory from the replay
Example fix
// before $ rm -rf build && ln -s /shared/build build # then replay fails // after $ unlink build && mkdir build # then re-run replay
Defensive patterns
Strategy: validation
Validate before calling
// preflight each restore dir
for dir in &restore_dirs {
if dir.exists() && !(dir.is_dir() && !dir.is_symlink()) {
eprintln!("clear the path first: {}", dir.display());
}
} Prevention
- Don't replace directories with files or symlinks after checkpoints
- Remove placeholders (files where empty dirs were) before replaying
- Verify symlink placement in synced/mounted directories
When it happens
Trigger: For dir in exec.restore_dirs: dir exists or is a symlink but is not a real directory at restore time.
Common situations: A file was created where an empty directory used to be after the checkpoint; a symlink now occupies the recorded directory path; sync tools replaced directories with symlinks.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- {} appeared after {} was protected; nothing more was changed
- the refreshed plan has conflicts; nothing was changed
- declined; nothing was changed
- these paths keep changing while being protected; nothing was
- {} changed after it was protected; nothing more was changed
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/95c0f19dc46d17a1.
Report an issue: GitHub.