{"record":{"id":"5e67135f42eb9eb4","repo":"jdx/mise","slug":"directory-cannot-be-present-while-managed-par","errorCode":null,"errorMessage":"directory '{}' cannot be present while managed parent '{}' is absent","messagePattern":"directory '(.+?)' cannot be present while managed parent '(.+?)' is absent","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/resources.rs","lineNumber":485,"sourceCode":"        let parent_id = ResourceId::new(\"directory\", parent.to_string_lossy());\n        match (directory.state, parent_state) {\n            (\n                super::managed_files::ManagedState::Present,\n                super::managed_files::ManagedState::Present,\n            ) => {\n                plan.add_dependency(&id, parent_id)?;\n            }\n            (\n                super::managed_files::ManagedState::Absent,\n                super::managed_files::ManagedState::Absent,\n            ) => {\n                plan.add_dependency(&parent_id, id)?;\n            }\n            (\n                super::managed_files::ManagedState::Present,\n                super::managed_files::ManagedState::Absent,\n            ) => {\n                bail!(\n                    \"directory '{}' cannot be present while managed parent '{}' is absent\",\n                    directory.path.display(),\n                    parent.display()\n                );\n            }\n            (\n                super::managed_files::ManagedState::Absent,\n                super::managed_files::ManagedState::Present,\n            ) => {}\n        }\n    }\n    for file in files {\n        let resource = file.plan()?;\n        let id = resource.id.clone();\n        plan.insert(resource)?;\n        add_account_dependencies(\n            &mut plan,\n            &id,","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/resources.rs#L467-L503","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Mark the parent directory Present (or remove its Absent declaration) so the child can exist","If the whole tree should be removed, mark the child Absent too","Reconcile the two resource declarations so parent/child states agree"],"exampleFix":"// before\n{\"path\": \"/opt/app\", \"state\": \"absent\"}\n{\"path\": \"/opt/app/logs\", \"state\": \"present\"}\n// after\n{\"path\": \"/opt/app\", \"state\": \"present\"}\n{\"path\": \"/opt/app/logs\", \"state\": \"present\"}","handlingStrategy":"validation","validationCode":"const states = new Map(dirs.map(d => [d.path, d.state]));\nfor (const d of dirs) {\n  const parent = dirname(d.path);\n  if (d.state === 'present' && states.get(parent) === 'absent') throw new Error(`${d.path} present but parent ${parent} absent`);\n}","typeGuard":"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'); }","tryCatchPattern":"try { plan = planner.plan(); } catch (e) { if (String(e).includes('cannot be present while managed parent')) { reconcileDirStates(config); } else throw e; }","preventionTips":["When marking a directory absent, audit and update every resource declared under it","Keep parent/child directory declarations in the same config block","Add a lint that any present resource has an explicit present ancestor chain"],"tags":["filesystem","directory","config-conflict"],"backgroundTag":"conflicting-config-options","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"}