{"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/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/replay.rs#L672-L708","documentation":"During restore, mise must recreate deleted directories. If a path that should become a directory currently exists as something else (a file or a symlink), mise refuses to clobber it and aborts the remaining restore. Already-applied steps remain recorded for undo.","triggerScenarios":"In the restore_dirs pass of apply_steps, a path in exec.restore_dirs exists (or is a symlink) but is not a real directory, so mkdir would fail or overwrite a non-directory entry.","commonSituations":"A file was created where a directory used to live after the checkpoint (e.g. a symlink replaced by a regular file, or a build tool wrote a file at the old directory path); leftover state from a prior partial restore.","solutions":["Inspect the path: if the file/symlink there is disposable, remove it and re-run the restore.","If it holds real data, move it elsewhere first, then re-run the rollback.","Restore a narrower scope that avoids the conflicting path."],"exampleFix":"# before\nls -la src/generated   # -> a regular file blocks the directory restore\nrm src/generated       # or: mv src/generated src/generated.bak\n# after\nmise history undo      # restore now succeeds","handlingStrategy":"validation","validationCode":"for d in $restore_dirs; do if [ -e \"$d\" ] && [ ! -d \"$d\" ]; then echo \"conflict: $d\"; fi; done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check that former directory paths are not occupied by files/symlinks before restoring.","Clean up prior partial restores before retrying.","Move unknown files aside rather than deleting when in doubt."],"tags":["history","filesystem","path-conflict","restore"],"backgroundTag":"file-already-exists","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"}