{"record":{"id":"95c0f19dc46d17a1","repo":"jdx/mise","slug":"cannot-be-recreated-as-a-directory-something-e","errorCode":null,"errorMessage":"{} cannot be recreated as a directory: something else is there now; nothing more was changed","messagePattern":"(.+?) cannot be recreated as a directory: something else is there now; nothing more was changed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/replay.rs","lineNumber":690,"sourceCode":"                }\n            }\n        });\n        let pending =\n            journal::begin_changes(\"history\", &display_path(&step.path), [step.path.clone()])?;\n        match &step.action {\n            Action::Write { mode, oid } => write_object(repo, step, mode, oid)?,\n            Action::Delete => remove(&step.path)?,\n            _ => unreachable!(\"filtered to mutating steps\"),\n        }\n        journal::commit_changes(pending);\n        touched.push(step.path.clone());\n    }\n    for dir in &exec.restore_dirs {\n        if dir.is_dir() && !dir.is_symlink() {\n            continue;\n        }\n        if dir.exists() || dir.is_symlink() {\n            bail!(\n                \"{} cannot be recreated as a directory: something else is there now; nothing more was changed\",\n                display_path(dir)\n            );\n        }\n        if let Some(parent) = dir.parent() {\n            file::create_dir_all(parent)?;\n        }\n        let bits = exec.restore_modes.get(&display_path(dir));\n        let builder = std::fs::DirBuilder::new();\n        #[cfg(unix)]\n        let builder = {\n            let mut builder = builder;\n            if let Some(bits) = bits {\n                use std::os::unix::fs::DirBuilderExt;\n                builder.mode(*bits);\n            }\n            builder\n        };","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/replay.rs#L672-L708","documentation":"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.","triggerScenarios":"For dir in exec.restore_dirs: dir exists or is a symlink but is not a real directory at restore time.","commonSituations":"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.","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"],"exampleFix":"// before\n$ rm -rf build && ln -s /shared/build build   # then replay fails\n// after\n$ unlink build && mkdir build                 # then re-run replay","handlingStrategy":"validation","validationCode":"// preflight each restore dir\nfor dir in &restore_dirs {\n    if dir.exists() && !(dir.is_dir() && !dir.is_symlink()) {\n        eprintln!(\"clear the path first: {}\", dir.display());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["history","replay","path-conflict","directory-restore"],"backgroundTag":"file-already-exists","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"}