can1357/oh-my-pi · error · ArchiveError
Unsupported RAR5 compression algorithm version ${version}
Error message
Unsupported RAR5 compression algorithm version ${version} What it means
RAR5 archives store a per-file compression algorithm version; this decoder only implements versions 0 and 1. When a member header declares a newer algorithm version, the decoder refuses to guess and throws ArchiveError instead of producing corrupt output.
Source
Thrown at packages/utils/src/ar/rar/rar5-decoder.ts:168
this.#history = new Uint8Array(0);
this.#reps = [0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff];
this.#lastLen = 0;
this.#main = new Huffman(MAIN_SIZE);
this.#dist = new Huffman(DIST_SIZE);
this.#align = new Huffman(ALIGN_SIZE);
this.#length = new Huffman(LEN_SIZE);
this.#useAlign = false;
}
decode(
packed: Uint8Array,
unpackedSize: number,
dictionarySize: number,
solid: boolean,
version: number,
): Uint8Array {
if (version !== 0 && version !== 1) {
throw new ArchiveError(`Unsupported RAR5 compression algorithm version ${version}`);
}
if (!solid) this.reset();
if (!Number.isSafeInteger(dictionarySize) || dictionarySize < 128 * 1024) fail("invalid dictionary size");
const prior =
this.#history.byteLength > dictionarySize
? this.#history.subarray(this.#history.byteLength - dictionarySize)
: this.#history;
const data = new Uint8Array(prior.byteLength + unpackedSize + MAX_MATCH);
data.set(prior);
let outPos = prior.byteLength;
const outStart = outPos;
const outEnd = outStart + unpackedSize;
const filters: Filter[] = [];
const bits = new Bits(packed);
const main = this.#main;
const dist = this.#dist;
const align = this.#align;
const lenDecoder = this.#length;View on GitHub (pinned to 9690622007)
Solutions
- Re-create the archive with WinRAR/unrar using RAR5 compression (not the RAR7/new algorithm) or store with -m0
- Upgrade to a decoder/library version that supports the newer RAR5 algorithm version
- Extract the member with the official unrar/WinRAR tool and re-pack before feeding it to this library
Example fix
// before: archive made with WinRAR 7 defaults (RAR7 algorithm) fails to decode // after: repack with RAR5-compatible compression // $ rar a -ma5 -m3 output.rar files/
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check RAR5 algorithm version from parsed metadata if available:
// records where format===5 and version>1 will fail
const risky = records.some(r => r.format === 5 && r.version > 1);
if (risky) console.warn('Archive uses unsupported RAR5 algorithm version; repack or use unrar'); Type guard
function isSupportedRar5Version(record: { format: number; version: number }): boolean {
return record.format !== 5 || record.version === 0 || record.version === 1;
} Try / catch
try {
const bytes = await reader.read(memberPath);
} catch (err) {
if (err instanceof ArchiveError && /algorithm version/.test(err.message)) {
// fall back to external unrar tooling
}
throw err;
} Prevention
- Create archives with -ma5 (not -ma7) when they will be consumed by this library
- Prefer standard compression methods (-m1..-m5) over newer algorithm variants
- Test archives with `unrar t` in CI before processing them
When it happens
Trigger: Decoding a RAR5 member whose compression header field 'version' is >= 2 (or negative/garbage), typically via readRar/extracting an archive created by a newer RAR (RAR7+) using a newer compression algorithm.
Common situations: Opening archives produced by WinRAR 7.x with the new RAR7 compression format using a decoder that only supports RAR5 v0/v1; corrupted header bytes flipping the version field.
Related errors
- Unsupported RAR4 compression algorithm version ${version}
- Unsupported RAR4 compression method 0x${(record.method + 0x3
- ARJ member '${memberPath}' uses unsupported compression meth
- Unsupported CAB format version ${fixed[25]}.${fixed[24]} (ex
- Unsupported RAR4 PPMd compressed block
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/c27e8ec5a6e7e84c.
Report an issue: GitHub.