{"record":{"id":"3a039ae706e6db3c","repo":"jdx/mise","slug":"declaring-bootstrap-config-is-loaded","errorCode":null,"errorMessage":"declaring bootstrap config is loaded","messagePattern":"declaring bootstrap config is loaded","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/mod.rs","lineNumber":1757,"sourceCode":"        .find(|cf| cf.monorepo_root() == Some(true))\n}\n\n/// Loads each selected bootstrap root as an independent hierarchy with scoped variables.\nasync fn load_bootstrap_config_maps(config: &Config) -> Result<Vec<BootstrapConfigMap>> {\n    let Some((declaring_config, patterns)) = config.config_files.iter().find_map(|(path, cf)| {\n        cf.bootstrap_config()\n            .and_then(|bootstrap| bootstrap.config_roots.map(|patterns| (path, patterns)))\n    }) else {\n        return Ok(vec![]);\n    };\n    if patterns.is_empty() {\n        return Ok(vec![]);\n    }\n\n    let declaring_root = config\n        .config_files\n        .get(declaring_config)\n        .expect(\"declaring bootstrap config is loaded\")\n        .config_root();\n    let mut roots = expand_bootstrap_config_roots(&declaring_root, &patterns)?;\n    roots.sort();\n    roots.dedup();\n    if roots.is_empty() {\n        bail!(\"[bootstrap].config_roots did not match any config roots\");\n    }\n\n    let mut base = config.config_files.clone();\n    base.retain(|path, _| {\n        is_global_config(path)\n            || !path\n                .canonicalize()\n                .is_ok_and(|path| roots.iter().any(|root| path.starts_with(root)))\n    });\n    let mut maps = vec![BootstrapConfigMap {\n        config_files: base,\n        tera_ctx: config.tera_ctx.clone(),","sourceCodeStart":1739,"sourceCodeEnd":1775,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/config/mod.rs#L1739-L1775","documentation":"mise panics with 'declaring bootstrap config is loaded' when `config.config_files.get(declaring_config)` returns `None` while expanding `[bootstrap].config_roots` patterns. The `declaring_config` index is expected to point at a config file that was loaded into the current config's `config_files` map; if the declaring file was not loaded (skipped include, filtered env, different config root), the lookup panics.","triggerScenarios":"A config file declares `[bootstrap].config_roots` but is not present in `config.config_files` when the roots are expanded — e.g. the declaring file is only reachable via an include that was not loaded, the declaration is resolved against a different config instance than the one that loaded it, or layered loading dropped the file.","commonSituations":"Users declare bootstrap config roots in a file included conditionally or in an env-specific config not active; referencing a declaring config from a stale index after config reload; refactors that pass the wrong config instance into the roots-expansion helper.","solutions":["Ensure the config instance passed to the roots-expansion code actually contains the declaring file in `config_files`","Check that the file declaring `[bootstrap].config_roots` is loaded (correct include path, active env, trusted)","Return a descriptive error instead of panicking when the declaring config is absent","Reproduce with the mise.toml layout whose bootstrap declaration triggers the missing lookup"],"exampleFix":"// before\nlet declaring_root = config.config_files.get(declaring_config)\n    .expect(\"declaring bootstrap config is loaded\").config_root();\n// after\nlet declaring_root = config.config_files.get(declaring_config)\n    .with_context(|| format!(\"declaring bootstrap config {declaring_config:?} not loaded\"))?\n    .config_root();","handlingStrategy":"validation","validationCode":"if !config.config_files.contains_key(declaring_config) { bail!(\"declaring bootstrap config not loaded\"); }","typeGuard":"config.config_files.get(declaring_config).is_some()","tryCatchPattern":null,"preventionTips":["Verify the declaring config file is included, active, and trusted before declaring bootstrap roots","Pass the same config instance that loaded the declaration into the expansion helper","Return a contextual error instead of expect for missing config files"],"tags":["rust","config","bootstrap","panic","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-14T00:17:10.932Z"}