jdx/mise · error

Size mismatch: expected {}, got {}

Error message

Size mismatch: expected {}, got {}

What it means

In verify_artifact (src/backend/static_helpers.rs:887), mise compares the downloaded artifact's on-disk size against the expected size declared in the backend's metadata (via lookup_with_fallback on the "size" option). If the file's actual byte length differs from the declared size, the download is assumed corrupt or truncated and installation aborts.

Source

Thrown at src/backend/static_helpers.rs:887

    file_path: &Path,
    opts: &crate::toolset::ToolVersionOptions,
    pr: Option<&dyn SingleReport>,
) -> Result<()> {
    // Check platform-specific checksum first, then fall back to generic
    let checksum = lookup_with_fallback(opts, "checksum");

    if let Some(checksum) = checksum {
        verify_checksum_str(file_path, &checksum, pr)?;
    }

    // Check platform-specific size first, then fall back to generic
    let size_str = lookup_with_fallback(opts, "size");

    if let Some(size_str) = size_str {
        let expected_size: u64 = size_str.parse()?;
        let actual_size = file_path.metadata()?.len();
        if actual_size != expected_size {
            bail!(
                "Size mismatch: expected {}, got {}",
                expected_size,
                actual_size
            );
        }
    }

    Ok(())
}

pub(crate) fn verify_checksum_str(
    file_path: &Path,
    checksum: &str,
    pr: Option<&dyn SingleReport>,
) -> Result<()> {
    if let Some((algo, hash_str)) = checksum.split_once(':') {
        hash::ensure_checksum(file_path, hash_str, pr, algo)?;
    } else {

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Delete the partial download and retry the install (mise install <tool> --force) to rule out truncation.
  2. Check whether a proxy/mirror is intercepting downloads (HTTP_PROXY, corporate TLS inspection) and bypass it for release hosts.
  3. Verify the upstream release asset has not been replaced/re-tagged; if so, wait for the backend metadata to be updated or pin the previous version.
  4. Report the mismatch to the backend maintainer if the declared size is stale.

Example fix

// before: corrupt cached artifact causes repeated failure
mise install node@22
// after: clear the download and reinstall
rm -rf ~/.cache/mise/downloads/<tool>/<version>
mise install node@22 --force
Defensive patterns

Strategy: validation

Validate before calling

// check expected vs actual size before installing
let meta = std::fs::metadata(&artifact_path)?;
let expected: u64 = cfg.get("size").parse()?;
if meta.len() != expected {
    eprintln!("artifact size {} != expected {} — redownload", meta.len(), expected);
}

Prevention

When it happens

Trigger: Installing a backend artifact whose "size" metadata exists but does not match the downloaded file: an interrupted/proxied download, a mirror serving a rewritten file, an upstream release asset replaced without updating the size field, or a transparent proxy injecting content.

Common situations: Corporate proxy or captive portal replaces the asset with an HTML error page; CDN cache poisoning; upstream maintainer re-tags/replaces a release asset; disk-full truncation during download.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/a315219df7aca1e3. Report an issue: GitHub.