{"record":{"id":"bc79d09e685ba6e2","repo":"jdx/mise","slug":"refusing-unsafe-change-to-bootstrap-service-bc79d0","errorCode":null,"errorMessage":"refusing unsafe change to bootstrap service '{}'; current state remains unknown after systemctl daemon-reload","messagePattern":"refusing unsafe change to bootstrap service '(.+?)'; current state remains unknown after systemctl daemon-reload","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/services.rs","lineNumber":440,"sourceCode":"        let Some(parent) = path.parent() else {\n            return false;\n        };\n        if !SYSTEM_UNIT_PATHS\n            .iter()\n            .any(|candidate| parent == *candidate)\n        {\n            return false;\n        }\n        path.file_name().is_some_and(|name| {\n            name == self.unit.as_str()\n                || instantiated_unit_template(&self.unit)\n                    .is_some_and(|template| name == template.as_str())\n        })\n    }\n\n    fn commands_after_reload(&self, notified: bool) -> Result<Vec<Vec<String>>> {\n        if self.plan().action == ResourceAction::Unknown {\n            bail!(\n                \"refusing unsafe change to bootstrap service '{}'; current state remains unknown after systemctl daemon-reload\",\n                self.name\n            );\n        }\n        Ok(self\n            .action(ServiceChange {\n                notified,\n                provides_unit: false,\n            })?\n            .map(|action| action.commands())\n            .unwrap_or_default())\n    }\n}\n\nconst SYSTEM_UNIT_PATHS: &[&str] = &[\n    \"/etc/systemd/system.control\",\n    \"/run/systemd/system.control\",\n    \"/run/systemd/transient\",","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/services.rs#L422-L458","documentation":"After performing `systemctl daemon-reload`, mise re-plans each bootstrap service before issuing follow-up commands. If the plan action is still `ResourceAction::Unknown` (unit still missing, inspection still unavailable, or the unit still cannot be enabled), mise aborts rather than apply changes to a service whose state remains unknown even after the reload.","triggerScenarios":"The apply pipeline reached `commands_after_reload` (daemon-reload already executed) but the unit is still absent on disk, systemctl is still unavailable, or the unit-file state is still non-enableable. Typical when a managed unit-file step failed or was skipped while the `[bootstrap.services]` entry references the unit.","commonSituations":"Unit file write failed or was reverted between steps; unit lives in a directory not scanned after reload; systemctl intermittently unavailable in the environment; a masked/static vendor unit that stays non-enableable.","solutions":["Run `mise bootstrap plan` to see the persisted `current` state for the service","Verify the unit exists: `systemctl cat <unit>` and `ls /etc/systemd/system/<unit>`","Run `sudo systemctl daemon-reload` and `systemctl status <unit>` manually to see what systemd reports","If the unit should be managed by mise, declare it under `[[bootstrap.files]]` so the missing-unit case is resolved by the same run","Align `enabled`/`masked` desires with what the unit actually supports (static units cannot be enabled)"],"exampleFix":"# before: service references a unit nothing installs\n[bootstrap.services.agent]\nstate = \"running\"\n\n# after: supply the unit so it exists before follow-up commands\n[[bootstrap.files]]\npath = \"/etc/systemd/system/agent.service\"\nsource = \"assets/agent.service\"\n\n[bootstrap.services.agent]\nstate = \"running\"","handlingStrategy":"validation","validationCode":"systemctl cat <unit> >/dev/null 2>&1 || echo \"unit missing: will stay unknown after daemon-reload\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep unit-file provisioning (`[[bootstrap.files]]`) and the service declaration in the same config so apply never reaches follow-up commands with a missing unit","Pin the exact unit path under /etc/systemd/system to avoid directory-scan misses after daemon-reload"],"tags":["mise","bootstrap","systemd","daemon-reload","systemctl"],"backgroundTag":"refuse-unsafe-state-change","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}