{"record":{"id":"b5076d761f8cd1ff","repo":"jdx/mise","slug":"refusing-to-remove-non-directory-path-as-a-dire","errorCode":null,"errorMessage":"refusing to remove non-directory path {} as a directory; declare it in [bootstrap.files]","messagePattern":"refusing to remove non-directory path (.+?) as a directory; declare it in \\[bootstrap\\.files\\]","errorType":"error_code","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/managed_files.rs","lineNumber":736,"sourceCode":"            recursive: config.recursive,\n            replace: config.replace,\n            notify: config.notify,\n            origin,\n            inspection: None,\n        })\n    }\n\n    pub(crate) fn plan(&self) -> Result<ResourcePlan> {\n        plan_directory(self).map(|plan| {\n            plan.with_origin(self.origin.clone())\n                .with_file_phase(self.phase)\n        })\n    }\n\n    fn operation(&self) -> Result<Option<PrivilegedAction>> {\n        match self.plan()?.action {\n            ResourceAction::Noop => return Ok(None),\n            ResourceAction::Unknown if self.state == ManagedState::Absent => bail!(\n                \"refusing to remove non-directory path {} as a directory; declare it in [bootstrap.files]\",\n                self.path.display()\n            ),\n            ResourceAction::Unknown => bail!(\n                \"refusing to replace non-directory path {}; set replace = true to allow replacement\",\n                self.path.display()\n            ),\n            _ => {}\n        }\n        Ok(Some(match self.state {\n            ManagedState::Present => PrivilegedAction::CreateDirectory {\n                path: self.path.clone(),\n                owner: self.owner.clone(),\n                group: self.group.clone(),\n                mode: self.mode,\n                replace: self.replace,\n            },\n            ManagedState::Absent => PrivilegedAction::RemoveDirectory {","sourceCodeStart":718,"sourceCodeEnd":754,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/managed_files.rs#L718-L754","documentation":"Mirror of error 1066 for directory resources: a [bootstrap.directories] entry with state = \"absent\" whose target path exists as a non-directory (regular file, symlink, etc.) cannot be removed with directory semantics, so operation() refuses and directs the user to declare it under [bootstrap.files].","triggerScenarios":"Executing a managed directory action where plan() returns ResourceAction::Unknown (path is not a directory) and the requested state is Absent.","commonSituations":"The path changed from directory to file between config authoring and execution; a package replaced a config directory with a plain file; stale cleanup declarations for refactored layouts.","solutions":["Move the entry to [bootstrap.files] with state = \"absent\" so it is removed as a file.","Delete the file manually if it should not be managed.","Fix the declared path if it was meant to reference a directory elsewhere."],"exampleFix":"# before\n[bootstrap.directories]\n\"/etc/app.conf\" = { state = \"absent\" }\n\n# after\n[bootstrap.files]\n\"/etc/app.conf\" = { state = \"absent\" }","handlingStrategy":"validation","validationCode":"// preflight: check on-disk kind before declaring a directory absent\nfn preflight_absent_dir(path: &Path) -> Result<(), String> {\n    match std::fs::symlink_metadata(path) {\n        Ok(md) if md.is_file() => Err(format!(\"{} is a file; declare it in [bootstrap.files]\", path.display())),\n        _ => Ok(()),\n    }\n}","typeGuard":null,"tryCatchPattern":"// treat the refusal as a config-classification error\nmatch result {\n    Err(e) if e.contains(\"refusing to remove non-directory\") => {\n        eprintln!(\"move entry to [bootstrap.files]: {}\", e);\n    }\n    other => other?,\n}","preventionTips":["Audit declared directories against the live filesystem before cleanup runs.","Update declarations whenever a package replaces a directory with a file.","Generate directory lists from a discovery step instead of hardcoding."],"tags":["managed-files","type-mismatch","filesystem"],"backgroundTag":"path-is-not-a-directory","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"}