jdx/mise · error

unsupported ELF class

Error message

unsupported ELF class

What it means

`elf_interpreter` reads EI_CLASS (byte 4): 1 = ELF32, 2 = ELF64; anything else is an invalid ELF class and parsing stops. This prevents reading program header tables with the wrong field layout/offsets, which would produce nonsense or out-of-bounds reads.

Solutions

  1. Reinstall mise so the binary is a genuine ELF32/ELF64 executable (`file $(which mise)` should say 'ELF 32-bit' or 'ELF 64-bit')
  2. Verify the binary's checksum against the release manifest
  3. Ensure the mise on PATH is the actual compiled binary, not a stub or placeholder

Example fix

// before
$ xxd -l 8 mise
00000000: 7f45 4c46 09 01 ...   # class byte 0x09 -> invalid
// after
# restore a valid binary
mise self-update   # or reinstall from release tarball
$ xxd -l 8 mise
00000000: 7f45 4c46 02 01 ...   # class 2 = ELF64
Defensive patterns

Strategy: validation

Validate before calling

fn valid_elf_class(bytes: &[u8]) -> bool {
    matches!(bytes.get(4), Some(1) | Some(2))
}

Type guard

fn is_plausible_elf(bytes: &[u8]) -> bool {
    bytes.starts_with(b"\\x7fELF") && matches!(bytes.get(4), Some(1) | Some(2))
        && matches!(bytes.get(5), Some(1) | Some(2))
}

Try / catch

match elf_interpreter(&bytes) {
    Err(e) if e.to_string().contains("unsupported ELF class") => {
        reinstall_mise()?; // binary on disk is corrupt
    }
    other => other?,
}

Prevention

When it happens

Trigger: A file passing the magic check but whose byte 4 is not 1 or 2 — corrupted binary, fuzzed input, or a fabricated file that begins with \"\\u{7f}ELF\" but is not a real ELF image.

Common situations: Corrupted mise binary on disk (bad download, filesystem corruption); a file mislabeled as the mise executable; adversarial or test fixture inputs.

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/e8758a9bddf2af13. Report an issue: GitHub.

Appendix: source

Thrown at src/system/remote.rs:1903

        Some(2) => false,
        _ => bail!("unsupported ELF byte order"),
    };
    let (program_offset, entry_size, entry_count, offset_field, size_field) = match class {
        1 => (
            read_elf_int(bytes, 28, 4, little_endian)?,
            read_elf_int(bytes, 42, 2, little_endian)?,
            read_elf_int(bytes, 44, 2, little_endian)?,
            4,
            16,
        ),
        2 => (
            read_elf_int(bytes, 32, 8, little_endian)?,
            read_elf_int(bytes, 54, 2, little_endian)?,
            read_elf_int(bytes, 56, 2, little_endian)?,
            8,
            32,
        ),
        _ => bail!("unsupported ELF class"),
    };
    let program_offset = usize::try_from(program_offset)?;
    let entry_size = usize::try_from(entry_size)?;
    let entry_count = usize::try_from(entry_count)?;
    for index in 0..entry_count {
        let start = program_offset
            .checked_add(
                index
                    .checked_mul(entry_size)
                    .ok_or_else(|| eyre!("invalid ELF program headers"))?,
            )
            .ok_or_else(|| eyre!("invalid ELF program headers"))?;
        if read_elf_int(bytes, start, 4, little_endian)? != PT_INTERP {
            continue;
        }
        let offset = usize::try_from(read_elf_int(
            bytes,
            start + offset_field,

View on GitHub (pinned to 533346cc37)