{"record":{"id":"467800e1e0e2859a","repo":"jdx/mise","slug":"refusing-to-overwrite-non-empty-directory-pass","errorCode":null,"errorMessage":"refusing to overwrite non-empty directory {}; pass {} or choose an empty/new path","messagePattern":"refusing to overwrite non-empty directory (.+?); pass (.+?) or choose an empty/new path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/install_into.rs","lineNumber":153,"sourceCode":"        // already exists at the install path. Check immediately before the\n        // install performs that deletion (rather than at the start of `run`) so\n        // a directory that became non-empty during tool resolution can't be\n        // clobbered without an explicit opt-in. Refuse to overwrite a non-empty\n        // directory (e.g. `.`) unless the user passes -y/--yes or confirms\n        // interactively; the prompt defaults to \"no\" since it is destructive.\n        // (#8115)\n        if path_has_contents(&install_path) {\n            let proceed = Settings::get().yes\n                || prompt::confirm_with_default(\n                    format!(\n                        \"{} is not empty; install-into will delete its contents. Continue?\",\n                        display_path(&install_path)\n                    ),\n                    false,\n                )?\n                .is_yes();\n            if !proceed {\n                bail!(\n                    \"refusing to overwrite non-empty directory {}; pass {} or choose an empty/new path\",\n                    display_path(&install_path),\n                    style(\"--yes\").yellow().for_stderr()\n                );\n            }\n        }\n        backend.install_version(install_ctx, tv).await?;\n        Ok(())\n    }\n}\n\n/// Replacement deletes the destination, so one that overlaps the lock directory\n/// in either direction is refused: an ancestor would take the whole directory\n/// with it, and a descendant could unlink an active lock file, letting the next\n/// process create a replacement and install alongside the holder.\nfn lock_dir_overlap(destination: &Path, lock_dir: &Path) -> eyre::Report {\n    eyre!(\n        \"install-into destination {} overlaps mise's lock directory {}; choose a different destination\",","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/install_into.rs#L135-L171","documentation":"This error is thrown by the install-into command when the target install directory exists, is non-empty, and the user has not confirmed proceeding (no --yes and declined the interactive prompt). It protects against clobbering an existing tool installation directory with a new install.","triggerScenarios":"Running `mise install-into` into a directory that already contains files, in a non-interactive context (or after answering 'no' at the prompt) without passing --yes.","commonSituations":"Re-running an install into a previously populated install dir; CI scripts hitting a stale directory from an earlier run; pointing install path at a shared or versioned directory that already has content.","solutions":["Re-run with --yes to confirm overwriting the non-empty directory","Remove or move the existing directory contents first, or choose an empty/new install path","In CI, pre-clean the target directory (rm -rf) before installing"],"exampleFix":"// before\nmise install-into node 22.0.0 ~/.local/share/mise/installs/node/22.0.0\n// after\nmise install-into node 22.0.0 ~/.local/share/mise/installs/node/22.0.0 --yes","handlingStrategy":"validation","validationCode":"INSTALL_PATH=\"$HOME/.local/share/mise/installs/node/22.0.0\"\nif [[ -d \"$INSTALL_PATH\" ]] && [[ -n \"$(ls -A \"$INSTALL_PATH\" 2>/dev/null)\" ]]; then\n  rm -rf \"$INSTALL_PATH\"   # or pass --yes to mise install-into\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-clean install target directories in CI before installing","Pass --yes deliberately only when overwriting is intended","Use fresh/empty install paths for reproducible installs"],"tags":["install","safety-check","cli"],"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"}