jdx/mise · error

invalid completion specification path

Error message

invalid completion specification path

What it means

A completion specification path is serialized as bytes and decoded into an OsString. On Windows it must be UTF-16 little-endian, so the byte length must be even; an odd-length buffer cannot be a valid wide string, so `decode_spec_path` bails. This indicates corruption or a producer/consumer mismatch in the completion spec blob.

Solutions

  1. Regenerate or re-download the completion specification so the path field is intact UTF-16
  2. Clear mise's packslip/completion cache and retry the install
  3. Verify you're not hand-editing or post-processing the spec file between write and read
  4. Ensure both producing and consuming mise versions are current and matched

Example fix

// before: odd-length byte buffer from a truncated spec
bytes = [0x67, 0x00, 0x68]  // 3 bytes
// after: re-fetch the spec so path is valid UTF-16LE
bytes = [0x67, 0x00, 0x68, 0x00]  // 4 bytes, even length
Defensive patterns

Strategy: validation

Validate before calling

if spec_path_bytes.len() % 2 != 0 { return Err('corrupt UTF-16LE path in completion spec'); }

Type guard

fn is_valid_wide_path(bytes: &[u8]) -> bool { bytes.len() % 2 == 0 }

Try / catch

match decode_spec_path(bytes) {
    Ok(path) => use(path),
    Err(e) => { invalidate_spec_cache(); refetch_spec()?; }
}

Prevention

When it happens

Trigger: Decoding a completion specification whose path field has an odd number of bytes on Windows — truncated file, hand-edited spec, or a spec written by a non-Windows producer without UTF-16 encoding.

Common situations: Shared caches or manifests copied from WSL/Linux into Windows mise; partial download of the completion spec; cross-version mise where the spec serialization changed.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src/packslip/completions.rs:42

            .encode_wide()
            .flat_map(u16::to_le_bytes)
            .collect()
    };
    base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(bytes)
}

pub(crate) fn decode_spec_path(encoded: &str) -> eyre::Result<std::path::PathBuf> {
    use base64::Engine;
    let bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(encoded)?;
    #[cfg(unix)]
    let path = {
        use std::os::unix::ffi::OsStringExt;
        std::ffi::OsString::from_vec(bytes)
    };
    #[cfg(windows)]
    let path = {
        use std::os::windows::ffi::OsStringExt;
        if !bytes.len().is_multiple_of(2) {
            eyre::bail!("invalid completion specification path");
        }
        let wide: Vec<_> = bytes
            .chunks_exact(2)
            .map(|b| u16::from_le_bytes([b[0], b[1]]))
            .collect();
        std::ffi::OsString::from_wide(&wide)
    };
    Ok(path.into())
}

pub(crate) fn clear(shell: &str) -> &'static str {
    match shell {
        "bash" | "zsh" => {
            "if typeset -f __mise_clear_completions >/dev/null; then __mise_clear_completions; unset -f __mise_clear_completions; fi\n"
        }
        "fish" => {
            "if functions -q __mise_clear_completions; __mise_clear_completions; functions -e __mise_clear_completions; end\n"

View on GitHub (pinned to 533346cc37)