jdx/mise · error · eyre::Report
refusing to remove non-directory path
Error message
refusing to remove non-directory path {} as a directory; declare it in [bootstrap.files] What it means
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].
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.
Example fix
# before
[bootstrap.directories]
"/etc/app.conf" = { state = "absent" }
# after
[bootstrap.files]
"/etc/app.conf" = { state = "absent" } Defensive patterns
Strategy: validation
Validate before calling
// preflight: check on-disk kind before declaring a directory absent
fn preflight_absent_dir(path: &Path) -> Result<(), String> {
match std::fs::symlink_metadata(path) {
Ok(md) if md.is_file() => Err(format!("{} is a file; declare it in [bootstrap.files]", path.display())),
_ => Ok(()),
}
} Try / catch
// treat the refusal as a config-classification error
match result {
Err(e) if e.contains("refusing to remove non-directory") => {
eprintln!("move entry to [bootstrap.files]: {}", e);
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: Executing a managed directory action where plan() returns ResourceAction::Unknown (path is not a directory) and the requested state is Absent.
Common situations: 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.
Related errors
- refusing to remove directory as a file
- refusing to remove directory
- is not a directory; resolve its type before pulling
- managed file parent is not a directory
- refusing to replace non-file path
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/b5076d761f8cd1ff.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/managed_files.rs:736
recursive: config.recursive,
replace: config.replace,
notify: config.notify,
origin,
inspection: None,
})
}
pub(crate) fn plan(&self) -> Result<ResourcePlan> {
plan_directory(self).map(|plan| {
plan.with_origin(self.origin.clone())
.with_file_phase(self.phase)
})
}
fn operation(&self) -> Result<Option<PrivilegedAction>> {
match self.plan()?.action {
ResourceAction::Noop => return Ok(None),
ResourceAction::Unknown if self.state == ManagedState::Absent => bail!(
"refusing to remove non-directory path {} as a directory; declare it in [bootstrap.files]",
self.path.display()
),
ResourceAction::Unknown => bail!(
"refusing to replace non-directory path {}; set replace = true to allow replacement",
self.path.display()
),
_ => {}
}
Ok(Some(match self.state {
ManagedState::Present => PrivilegedAction::CreateDirectory {
path: self.path.clone(),
owner: self.owner.clone(),
group: self.group.clone(),
mode: self.mode,
replace: self.replace,
},
ManagedState::Absent => PrivilegedAction::RemoveDirectory {View on GitHub (pinned to 533346cc37)