rust-lang/rust · error · anyhow::Error

invalid compression profile: {other}

Error message

invalid compression profile: {other}

What it means

Thrown by CompressionProfile::from_str in the rust-installer compression module. The parser accepts exactly four strings: "fast", "balanced", "best", and "no-op" (compression.rs:26-32). Any other value is captured as {other} and causes this bail. CompressionProfile controls the compression level used when producing installer tarballs.

Source

Thrown at src/tools/rust-installer/src/compression.rs:31

#[derive(Default, Debug, Copy, Clone)]
pub enum CompressionProfile {
    NoOp,
    Fast,
    #[default]
    Balanced,
    Best,
}

impl FromStr for CompressionProfile {
    type Err = Error;

    fn from_str(input: &str) -> Result<Self, Error> {
        Ok(match input {
            "fast" => Self::Fast,
            "balanced" => Self::Balanced,
            "best" => Self::Best,
            "no-op" => Self::NoOp,
            other => anyhow::bail!("invalid compression profile: {other}"),
        })
    }
}

impl fmt::Display for CompressionProfile {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            CompressionProfile::Fast => f.write_str("fast"),
            CompressionProfile::Balanced => f.write_str("balanced"),
            CompressionProfile::Best => f.write_str("best"),
            CompressionProfile::NoOp => f.write_str("no-op"),
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum CompressionFormat {
    Gz,

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. Set --compression-profile to one of: fast, balanced, best, no-op.
  2. If unset, the default is Balanced (the #[default] attribute on the enum), so simply removing the explicit value also works.
  3. Check bootstrap.example.toml or the Combiner/Tarballer arg definitions for the canonical accepted values.

Example fix

# before
--compression-profile high
# after
--compression-profile best
Defensive patterns

Strategy: validation

Validate before calling

// Validate the profile string before passing it to the installer.
const VALID_PROFILES: &[&str] = &["fast", "balanced", "best", "no-op"];

fn validate_compression_profile(profile: &str) -> Result<(), String> {
    if VALID_PROFILES.contains(&profile) {
        Ok(())
    } else {
        Err(format!("invalid compression profile '{}': valid values are {:?}", profile, VALID_PROFILES))
    }
}

Prevention

When it happens

Trigger: Setting the compression_profile field (via CLI --compression-profile or the actor! macro's arg parsing) to a string that is not one of fast/balanced/best/no-op. For example "speed", "high", "level9", or an empty string.

Common situations: Typo in a bootstrap configuration value; using a compression level name from another tool (e.g., "level=9" from xz) instead of the rust-installer vocabulary; stale config from an older version that used different names.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/6f593e53bffde835. Report an issue: GitHub.