rust-lang/rust · error · anyhow::Error
unknown compression format: {}
Error message
unknown compression format: {} What it means
Thrown by CompressionFormats::try_from<&str> in the rust-installer compression module. The parser splits the input by commas and accepts only "gz" and "xz" per element (compression.rs:137-147). Any unrecognized token becomes {other} and triggers this bail. CompressionFormats determines which compressed tarballs are produced by the Tarballer.
Source
Thrown at src/tools/rust-installer/src/compression.rs:143
CompressionFormat::Xz => Box::new(XzDecoder::new(file)),
})
}
}
/// This struct wraps Vec<CompressionFormat> in order to parse the value from the command line.
#[derive(Debug, Clone)]
pub struct CompressionFormats(Vec<CompressionFormat>);
impl TryFrom<&'_ str> for CompressionFormats {
type Error = Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
let mut parsed = Vec::new();
for format in value.split(',') {
match format.trim() {
"gz" => parsed.push(CompressionFormat::Gz),
"xz" => parsed.push(CompressionFormat::Xz),
other => anyhow::bail!("unknown compression format: {}", other),
}
}
Ok(CompressionFormats(parsed))
}
}
impl FromStr for CompressionFormats {
type Err = Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
Self::try_from(value)
}
}
impl fmt::Display for CompressionFormats {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for (i, format) in self.iter().enumerate() {
if i != 0 {View on GitHub (pinned to 7088e4b63a)
Solutions
- Use only the short tokens gz and xz, separated by commas — e.g., "gz,xz" (the default) or "xz" only.
- Check for trailing/leading commas or extra whitespace that produces an empty token.
- If you need a new format, extend CompressionFormats::try_from and CompressionFormat with the new variant, encoder, and decoder.
Example fix
# before --compression-formats gzip,bzip2 # after --compression-formats gz,xz
Defensive patterns
Strategy: validation
Validate before calling
// Validate each format token in the comma-separated list.
fn validate_compression_formats(formats: &str) -> Result<(), String> {
for token in formats.split(',') {
let token = token.trim();
match token {
"gz" | "xz" => {}
"" => return Err("empty format token (check for trailing commas)".into()),
other => return Err(format!("unknown compression format '{}': only 'gz' and 'xz' are supported", other)),
}
}
Ok(())
} Prevention
- Use short tokens gz and xz — not gzip, bzip2, or zstd.
- Avoid trailing commas in the comma-separated list.
- Default is 'gz,xz' which produces both formats.
When it happens
Trigger: Setting the compression_formats field (via CLI --compression-formats or actor! arg) to a comma-separated list containing an unsupported format token. Examples: "gz,bz2", "zst", "gzip,xz" (must be "gz" not "gzip"), or an empty element from a trailing comma.
Common situations: Using full algorithm names ("gzip", "bzip2") instead of the short forms ("gz", "xz"); trailing comma producing an empty token; requesting zstd support that does not exist in this tool.
Related errors
- invalid compression profile: {other}
- couldn't figure out the format of {}
- Error: unable to find a config file for the given path: `{}`
- failed to find config line for {}
- config key {} not in sections or top_level_keys
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/edcae61fa11bdf11.
Report an issue: GitHub.