jdx/mise · error
file '{}' cannot be present while managed parent '{}' is abs
Error message
file '{}' cannot be present while managed parent '{}' is absent What it means
This error is thrown when the declarative file-resource planner detects a state contradiction: a managed file is requested to be Present while the managed parent directory it lives under is requested to be Absent. The planner refuses to build such a plan because it cannot both create and delete the containing directory chain in a consistent order. It is a plan-time (pre-apply) guard, so nothing is modified when it fires.
Source
Thrown at src/system/resources.rs:512
let parent_id = ResourceId::new("directory", parent.to_string_lossy());
match (file.state, parent_state) {
(
super::managed_files::ManagedState::Present,
super::managed_files::ManagedState::Present,
) => {
plan.add_dependency(&id, parent_id)?;
}
(
super::managed_files::ManagedState::Absent,
super::managed_files::ManagedState::Absent,
) => {
plan.add_dependency(&parent_id, id)?;
}
(
super::managed_files::ManagedState::Present,
super::managed_files::ManagedState::Absent,
) => {
bail!(
"file '{}' cannot be present while managed parent '{}' is absent",
file.path.display(),
parent.display()
);
}
(
super::managed_files::ManagedState::Absent,
super::managed_files::ManagedState::Present,
) => {}
}
}
}
for resource in unavailable_files {
plan.insert(resource)?;
}
let service_dependencies = plan
.resources
.keys()View on GitHub (pinned to afd2eddd3a)
Solutions
- Set the parent directory resource to state Present (or stop managing it as Absent) so the child file can exist.
- Remove or set to Absent the child file resources that live under the directory being removed.
- Reconcile the two declarations so both agree: if the tree is going away, mark children absent too; if children stay, the parent must stay.
- Fix path mismatches (trailing slashes, symlinks, relative vs absolute paths) if the parent/child relationship is accidental.
Example fix
// before
managed_dir("/opt/app", ManagedState::Absent);
managed_file("/opt/app/config.toml", ManagedState::Present);
// after
managed_dir("/opt/app", ManagedState::Present);
managed_file("/opt/app/config.toml", ManagedState::Present); Defensive patterns
Strategy: validation
Validate before calling
fn validate_parent_child(dir: (&str, bool), file: (&str, bool)) -> Result<(), String> {
let (dir_path, dir_present) = dir;
let (file_path, file_present) = file;
if file_present && !dir_present && file_path.starts_with(dir_path) {
return Err(format!("{file_path} is present but parent {dir_path} is absent"));
}
Ok(())
} Prevention
- Keep desired-state for a directory tree in one place so parent/child states cannot diverge
- When removing a directory, audit all resources under that path and mark them absent too
- Lint config for files whose path is a prefix-child of a directory declared absent
- Use consistent path normalization (absolute, no trailing slash) so parent relationships are detected
When it happens
Trigger: Calling the planning phase (plan) where one resource declares a parent directory with managed state Absent and another resource declares a file inside that directory with managed state Present; plan.add_dependency for the parent has already succeeded, so the contradiction is in requested states, not ordering.
Common situations: Splitting desired-state config across files where one module removes a directory (state = absent) while another module still manages config files inside it; leftover file entries after a refactor that deleted the parent directory resource; typos in the parent path so two resources disagree about which path is the parent.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- rustc output is not a regular file: {}
- failed to create file symlink: {err}
- {other:?}
- failed rename: {} -> {}: {err}
- {err} dotfiles: rollback failed: {rollback_err}
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/46581fade5f75f20.
Report an issue: GitHub.