denoland/deno · error

unknown --compress format '{other}' (use xz or zstd)

Error message

unknown --compress format '{other}' (use xz or zstd)

What it means

Thrown by the self-extracting bundle compression step in `deno desktop` when the `--compress <format>` value matches neither the xz branch ("xz"/"lzma", liblzma preset 9) nor the zstd branch ("zstd", level 19). The match is exact and case-sensitive, so any other string — including common archive names or case variants — bails with this message.

Source

Thrown at cli/tools/desktop.rs:933

  let out = std::fs::File::create(dest_file).with_context(|| {
    format!("failed to create payload {}", dest_file.display())
  })?;
  let out = std::io::BufWriter::new(out);
  match format {
    "xz" | "lzma" => {
      // Preset 9 ≈ `xz -9`; PRESET_EXTREME trades a lot of CPU for a few
      // percent, so stick to plain 9 for build-time sanity.
      let mut enc = liblzma::write::XzEncoder::new(out, 9);
      enc.write_all(&tar_buf)?;
      enc.finish()?.flush()?;
    }
    "zstd" => {
      let mut enc = zstd::stream::write::Encoder::new(out, 19)?;
      enc.write_all(&tar_buf)?;
      enc.finish()?.flush()?;
    }
    other => bail!("unknown --compress format '{other}' (use xz or zstd)"),
  }
  let comp_len = std::fs::metadata(dest_file).map(|m| m.len()).unwrap_or(0);
  Ok((raw_len, comp_len))
}

/// Short, stable cache key derived from the payload bytes — bumps the
/// extraction directory whenever the app contents change.
fn payload_hash(payload: &Path) -> Result<String, AnyError> {
  let bytes = std::fs::read(payload)?;
  let digest = sha2::Sha256::digest(&bytes);
  Ok(faster_hex::hex_string(&digest)[..16].to_string())
}

fn payload_ext(format: &str) -> &'static str {
  match format {
    "zstd" => "tar.zst",
    _ => "tar.xz",
  }

View on GitHub (pinned to f7822238ca)

Solutions

  1. Use exactly `xz` or `zstd`, lowercase: `--compress xz` (smallest) or `--compress zstd` (faster).
  2. If you typed `zst`, `gzip`, or `lzma`-adjacent names, correct to `xz` (lzma is accepted as an alias) or `zstd`.
  3. Omit `--compress` entirely to keep the tool's default behavior.

Example fix

# before
deno desktop compile --compress gzip main.ts

# after
deno desktop compile --compress zstd main.ts
Defensive patterns

Strategy: validation

Validate before calling

# bash: pin the value to the supported set
COMPRESS="${COMPRESS:-zstd}"
case "$COMPRESS" in xz|lzma|zstd) ;; *) echo "--compress must be xz or zstd" >&2; exit 1;; esac
deno desktop compile --compress "$COMPRESS" main.ts

Type guard

// TypeScript
function isSupportedCompressFormat(v: string): v is "xz" | "lzma" | "zstd" {
  return v === "xz" || v === "lzma" || v === "zstd";
}

Prevention

When it happens

Trigger: `deno desktop compile --compress gzip`, `--compress 7z`, `--compress tar.gz`, `--compress zip`, `--compress XZ` (uppercase), or a typo like `--compress zst` (the accepted spelling is `zstd`).

Common situations: Muscle memory from other tools where `--compress gzip` or `--compression 9` is valid; assuming `zst` is the flag spelling because that is the file extension; a config file carrying a compress value copied from a tar/docker command; uppercase spelling from env-var conventions.

Related errors


AI-assisted analysis of denoland/deno@f7822238ca (2026-08-20). Data as JSON: /api/errors/1b2c8f2fbc2fcecb. Report an issue: GitHub.