jdx/mise · error

privileged path inspection returned an unexpected result cou

Error message

privileged path inspection returned an unexpected result count

What it means

When mise must elevate to inspect managed paths, it re-executes itself as a privileged helper (<exe> --no-config --no-env --no-hooks bootstrap __inspect-system-files) and parses stdout as JSON, expecting exactly one PathInspection record per requested target. This error means the helper returned a different record count than targets, so results cannot be zipped onto requests; mise aborts rather than associate metadata with the wrong paths.

Source

Thrown at src/system/managed_files.rs:1050

    if privileged.is_empty() {
        return Ok(());
    }
    let input = serde_json::to_vec(&PrivilegedInspectionPlan { paths: privileged })?;
    let executable = std::env::current_exe()?.to_string_lossy().to_string();
    let output = crate::system::sudo::run_with_input_output(
        &executable,
        &[
            "--no-config".to_string(),
            "--no-env".to_string(),
            "--no-hooks".to_string(),
            "bootstrap".to_string(),
            "__inspect-system-files".to_string(),
        ],
        &input,
    )?;
    let inspections: Vec<PathInspection> = serde_json::from_slice(&output)?;
    if inspections.len() != targets.len() {
        bail!("privileged path inspection returned an unexpected result count");
    }
    for (target, inspection) in targets.into_iter().zip(inspections) {
        match target {
            Target::File(index) => files[index].inspection = Some(inspection),
            Target::Directory(index) => directories[index].inspection = Some(inspection),
        }
    }
    Ok(())
}

fn plan_directory(request: &ManagedDirectoryRequest) -> Result<ResourcePlan> {
    let desired = match request.state {
        ManagedState::Present => desired_metadata(
            "directory",
            request.mode,
            request.owner.as_deref(),
            request.group.as_deref(),
        ),

View on GitHub (pinned to 9dcfcaa0dc)

Solutions

  1. Verify the same binary gets elevated: compare mise --version with sudo "$(command -v mise)" --version and make them match
  2. Remove the duplicate mise install or fix sudo secure_path / PATH so root resolves the identical mise
  3. Re-run the bootstrap after fixing binary pairing
  4. If versions match and it still fails, run sudo "$(command -v mise)" --no-config --no-env --no-hooks bootstrap __inspect-system-files manually with the JSON input to inspect output, then report a bug with both versions

Example fix

# before: sudo may resolve a different mise from PATH
sudo mise bootstrap

# after: elevate the exact same binary the user runs
sudo "$(command -v mise)" bootstrap
Defensive patterns

Strategy: retry

Validate before calling

// before invoking the privileged flow, confirm root sees the same binary
use std::process::Command;
let mine = std::env::current_exe()?;
let out = Command::new("sudo").arg(&mine).arg("--version").output()?;
if !out.status.success() {
    return Err(eyre::eyre!("cannot elevate {:?} to verify version parity", mine));
}

Try / catch

match inspect_privileged(&targets).await {
    Err(e) if e.to_string().contains("unexpected result count") => {
        // verify mise binary pairing (mise --version vs sudo mise --version),
        // fix PATH/secure_path, then retry the bootstrap once
    }
    other => other,
}

Prevention

When it happens

Trigger: sudo PATH/secure_path resolution picks a different (older or newer) mise binary than the invoking one; a wrapper script or shim intercepts the elevated exec and alters output; truncated or corrupted stdout from the helper; a modified build emitting a different record count.

Common situations: mise installed twice (e.g. /usr/bin/mise and ~/.local/bin/mise) and sudo secure_path resolves the stale one after an upgrade; a root-only wrapper in PATH rewrites mise output.

Related errors


AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17). Data as JSON: /api/errors/ef392a4a18b65cd6. Report an issue: GitHub.