jdx/mise · error

directory ' ' cannot be present while managed parent ' ' is…

Error message

directory '{}' cannot be present while managed parent '{}' is absent

What it means

While planning a managed directory, the provisioner found the directory marked Present while its managed parent directory is marked Absent. That state is unrepresentable in the plan, so planning fails rather than emit a plan that creates a child under a directory it would delete or never create.

Solutions

  1. Mark the parent directory Present (or remove its Absent declaration) so the child can exist
  2. If the whole tree should be removed, mark the child Absent too
  3. Reconcile the two resource declarations so parent/child states agree

Example fix

// before
{"path": "/opt/app", "state": "absent"}
{"path": "/opt/app/logs", "state": "present"}
// after
{"path": "/opt/app", "state": "present"}
{"path": "/opt/app/logs", "state": "present"}
Defensive patterns

Strategy: validation

Validate before calling

const states = new Map(dirs.map(d => [d.path, d.state]));
for (const d of dirs) {
  const parent = dirname(d.path);
  if (d.state === 'present' && states.get(parent) === 'absent') throw new Error(`${d.path} present but parent ${parent} absent`);
}

Type guard

function parentStatesAgree(dirs) { const byPath = new Map(dirs.map(d => [d.path, d.state])); return dirs.every(d => d.state !== 'present' || byPath.get(dirname(d.path)) !== 'absent'); }

Try / catch

try { plan = planner.plan(); } catch (e) { if (String(e).includes('cannot be present while managed parent')) { reconcileDirStates(config); } else throw e; }

Prevention

When it happens

Trigger: Calling plan (via the resource planner) with a directory resource whose ManagedState is Present while add_directory_parent resolved the parent directory's ManagedState to Absent.

Common situations: Config drift: the parent directory was manually deleted or is declared absent in one block while a child block still says present; conflicting managed_files declarations between layered config files.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/5e67135f42eb9eb4. Report an issue: GitHub.

Appendix: source

Thrown at src/system/resources.rs:485

        let parent_id = ResourceId::new("directory", parent.to_string_lossy());
        match (directory.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!(
                    "directory '{}' cannot be present while managed parent '{}' is absent",
                    directory.path.display(),
                    parent.display()
                );
            }
            (
                super::managed_files::ManagedState::Absent,
                super::managed_files::ManagedState::Present,
            ) => {}
        }
    }
    for file in files {
        let resource = file.plan()?;
        let id = resource.id.clone();
        plan.insert(resource)?;
        add_account_dependencies(
            &mut plan,
            &id,

View on GitHub (pinned to 533346cc37)