SeleniumHQ/selenium · error · anyhow::Error
Format for file {} cannot be inferred
Error message
Format for file {} cannot be inferred What it means
Raised in uncompress() (files.rs:143) when the `infer` crate cannot determine the file type from its bytes AND the filename does not end with .pkg or .dmg. Selenium Manager has no fallback to identify the format and aborts. The filename is included in the message.
Source
Thrown at rust/src/files.rs:143
pub fn uncompress(
compressed_file: &str,
target: &Path,
log: &Logger,
os: &str,
single_file: Option<String>,
volume: Option<&str>,
) -> Result<(), Error> {
let mut extension = match infer::get_from_path(compressed_file)? {
Some(kind) => kind.extension(),
_ => {
if compressed_file.ends_with(PKG) || compressed_file.ends_with(DMG) {
if MACOS.is(os) {
PKG
} else {
return Err(anyhow!(format_one_arg(UNCOMPRESS_MACOS_ERR_MSG, PKG)));
}
} else {
return Err(anyhow!(format!(
"Format for file {} cannot be inferred",
compressed_file
)));
}
}
};
if compressed_file.ends_with(DMG) {
if MACOS.is(os) {
extension = DMG;
} else {
return Err(anyhow!(format_one_arg(UNCOMPRESS_MACOS_ERR_MSG, DMG)));
}
}
log.trace(format!(
"The detected extension of the compressed file is {}",
extension
));
View on GitHub (pinned to aa36b38e69)
Solutions
- Re-download the file; partial downloads are the most common cause.
- Inspect the file with `file <path>` and check its size is non-zero.
- Verify the download URL points to a real archive endpoint, not an error page.
- If the format is genuinely unsupported, convert it upstream to zip/tar.gz.
Defensive patterns
Strategy: validation
Validate before calling
# Bash: verify the downloaded file is non-empty and a known archive before extraction if [ ! -s "$FILE" ]; then echo "Empty/truncated download"; exit 1; fi file "$FILE"
Try / catch
match uncompress(file, target, &log, os, single, vol) {
Ok(()) => (),
Err(e) if e.to_string().contains("cannot be inferred") => {
eprintln!("Re-download {}; possibly truncated", file);
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Check downloaded file size is non-zero before extraction.
- Verify download URLs point to real archive endpoints.
- Re-download on partial/corrupt files.
When it happens
Trigger: infer::get_from_path returns None and the filename extension is neither PKG nor DMG. The else branch at line 142 returns the error. Typical when the downloaded file is empty, a truncated download, or an unsupported format.
Common situations: A partial/empty download (network drop produced 0 bytes); the server returned an HTML error page saved with a driver filename; an unsupported container (e.g. zstd, rar); filesystem gave 0 bytes.
Related errors
- Downloaded file cannot be uncompressed ({} extension)
- Wrong browser/driver version
- Unsuccessful response ({}) for URL {}
- Error parsing JSON from URL {} {}
- Unsafe entry (path traversal): {:?}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/1de640b985f2e1c5.
Report an issue: GitHub.