{"record":{"id":"81db7632567b3d3d","repo":"jdx/mise","slug":"system-files-were-preflighted-when-not-skipped","errorCode":null,"errorMessage":"system files were preflighted when not skipped","messagePattern":"system files were preflighted when not skipped","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/bootstrap.rs","lineNumber":1519,"sourceCode":"                    dry_run: self.dry_run,\n                    update: self.update,\n                    yes: self.yes,\n                };\n                driver::run(mgrs, Action::Install, &opts).await?;\n            }\n            if !has_plugin_packages {\n                self.run_hooks(&config, &hooks, BootstrapHookPhase::PostPackages)\n                    .await?;\n                post_packages_ran = true;\n            }\n        }\n\n        if skip.contains(&BootstrapPart::Files) {\n            debug!(\"bootstrap: system files skipped\");\n        } else {\n            let (mut files, mut directories) = managed_system_files\n                .as_ref()\n                .expect(\"system files were preflighted when not skipped\")\n                .clone();\n            system::managed_files::inspect_requests(&mut files, &mut directories)?;\n            if files.is_empty() && directories.is_empty() {\n                debug!(\"bootstrap: no [bootstrap.files] or [bootstrap.directories] configured\");\n            } else {\n                info!(\"bootstrap: system files\");\n                let report = system::managed_files::apply_with_accounts(\n                    &files,\n                    &directories,\n                    configured_accounts.as_ref(),\n                    allow_pending_accounts,\n                    self.dry_run,\n                    self.yes,\n                )?;\n                notified_services = report.notified_services;\n            }\n        }\n","sourceCodeStart":1501,"sourceCodeEnd":1537,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/bootstrap.rs#L1501-L1537","documentation":"A `.expect()` panic in mise's bootstrap system-files phase (src/cli/bootstrap.rs:1519). It asserts that when the Files part is not skipped, the earlier preflight stored its result in `managed_system_files`. Panicking means the file phase ran without the preflight ever populating that value.","triggerScenarios":"The Files part is executed (not in the skip list) but `managed_system_files` is None — the preflight pass that builds managed files/directories was not run, failed silently, or its result was dropped before this phase.","commonSituations":"Partial bootstrap invocations where phases are reordered; test harnesses that call the files phase directly without the preflight; refactors removing the preflight call.","solutions":["Ensure preflight always runs when BootstrapPart::Files is not skipped","Clone/store the preflight result into managed_system_files before dispatching phases","Change the phase to run preflight lazily if managed_system_files is None"],"exampleFix":"// before\nlet (mut files, mut directories) = managed_system_files.as_ref().expect(\"system files were preflighted when not skipped\").clone();\n// after\nlet (mut files, mut directories) = match managed_system_files.as_ref() { Some(v) => v.clone(), None => preflight_managed_files(&config)? };","handlingStrategy":"validation","validationCode":"if !skip.contains(&BootstrapPart::Files) && managed_system_files.is_none() { return Err(anyhow!(\"system files preflight missing\")); }","typeGuard":"fn preflighted(v: &Option<(Vec<FileRequest>, Vec<DirRequest>)>) -> bool { v.is_some() }","tryCatchPattern":"let Some(preflighted) = managed_system_files.as_ref() else { bail!(\"system files phase requires preflight\") };","preventionTips":["Run all preflights in a single setup step before phase dispatch","Assert in debug builds that preflight ran when Files is not skipped","Avoid calling phase functions directly outside the dispatcher"],"tags":["rust","panic","bootstrap","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}