{"record":{"id":"ef392a4a18b65cd6","repo":"jdx/mise","slug":"privileged-path-inspection-returned-an-unexpected","errorCode":null,"errorMessage":"privileged path inspection returned an unexpected result count","messagePattern":"privileged path inspection returned an unexpected result count","errorType":"error_code","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/managed_files.rs","lineNumber":1227,"sourceCode":"    if privileged.is_empty() {\n        return Ok(());\n    }\n    let input = serde_json::to_vec(&PrivilegedInspectionPlan { paths: privileged })?;\n    let executable = std::env::current_exe()?.to_string_lossy().to_string();\n    let output = crate::system::sudo::run_with_input_output(\n        &executable,\n        &[\n            \"--no-config\".to_string(),\n            \"--no-env\".to_string(),\n            \"--no-hooks\".to_string(),\n            \"bootstrap\".to_string(),\n            \"__inspect-system-files\".to_string(),\n        ],\n        &input,\n    )?;\n    let inspections: Vec<PathInspection> = serde_json::from_slice(&output)?;\n    if inspections.len() != targets.len() {\n        bail!(\"privileged path inspection returned an unexpected result count\");\n    }\n    for (target, inspection) in targets.into_iter().zip(inspections) {\n        match target {\n            Target::File(index) => files[index].inspection = Some(inspection),\n            Target::Directory(index) => directories[index].inspection = Some(inspection),\n        }\n    }\n    Ok(())\n}\n\nfn plan_directory(request: &ManagedDirectoryRequest) -> Result<ResourcePlan> {\n    let desired = match request.state {\n        ManagedState::Present => desired_metadata(\n            \"directory\",\n            request.mode,\n            request.owner.as_deref(),\n            request.group.as_deref(),\n        ),","sourceCodeStart":1209,"sourceCodeEnd":1245,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/managed_files.rs#L1209-L1245","documentation":"The privileged helper subprocess (`mise bootstrap __inspect-system-files`, run under sudo) returns a JSON array of path inspections that must line up 1:1 with the requested targets. When the counts diverge — meaning the helper returned malformed or truncated results — mise bails instead of indexing out of bounds. This is an internal consistency check.","triggerScenarios":"The deserialized `Vec<PathInspection>` length differs from `targets.len()` after running the privileged inspect helper; caused by a version mismatch between the invoking mise binary and the binary executed via sudo (different install paths), or corrupted/interleaved subprocess output.","commonSituations":"mise was upgraded between the unprivileged invocation and the sudo re-exec picking up an older binary on PATH; non-mise output contaminating the child's stdout; a partially failed subprocess still exiting 0.","solutions":["Re-run the command so sudo re-executes the same (current) mise binary; verify with `which mise` and `mise --version`.","Update mise everywhere on the machine so no stale copy is invoked via sudo.","If it persists, report as a bug — this indicates a corrupted privileged-helper exchange (include `MISE_DEBUG=1` output)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// retry once after ensuring the same binary is used for sudo re-exec\nmatch run_bootstrap_plan().await {\n    Err(e) if e.to_string().contains(\"unexpected result count\") => {\n        ensure_single_mise_binary()?;\n        run_bootstrap_plan().await\n    }\n    other => other,\n}","preventionTips":["Keep only one mise binary on PATH (avoid shadowed old installs).","Re-run after upgrading mise so sudo picks up the same version.","Avoid piping/altering stdout of mise bootstrap subprocesses."],"tags":["internal","subprocess","deserialization","bootstrap"],"backgroundTag":"unexpected-response-shape","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"}