{"record":{"id":"d108c27ab25be89a","repo":"pola-rs/polars","slug":"the-crate-was-compiled-without-ipc-compression-us-d108c2","errorCode":null,"errorMessage":"The crate was compiled without IPC compression. Use `io_ipc_compression` to write compressed IPC.","messagePattern":"The crate was compiled without IPC compression\\. Use `io_ipc_compression` to write compressed IPC\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/polars-arrow/src/io/ipc/compression.rs","lineNumber":67,"sourceCode":"}\n\n#[cfg(feature = \"io_ipc_compression\")]\n#[cfg_attr(docsrs, doc(cfg(feature = \"io_ipc_compression\")))]\npub fn compress_zstd(\n    input_buf: &[u8],\n    output_buf: &mut (impl std::io::Write + ?Sized),\n    level: ZstdLevel,\n) -> PolarsResult<()> {\n    zstd::stream::copy_encode(input_buf, output_buf, level.compression_level())\n        .map_err(|e| e.into())\n}\n\n#[cfg(not(feature = \"io_ipc_compression\"))]\npub fn compress_lz4(\n    _input_buf: &[u8],\n    _output_buf: &mut (impl std::io::Write + ?Sized),\n) -> PolarsResult<()> {\n    panic!(\n        \"The crate was compiled without IPC compression. Use `io_ipc_compression` to write compressed IPC.\"\n    )\n}\n\n#[cfg(not(feature = \"io_ipc_compression\"))]\npub fn compress_zstd(\n    _input_buf: &[u8],\n    _output_buf: &mut (impl std::io::Write + ?Sized),\n    _level: ZstdLevel,\n) -> PolarsResult<()> {\n    panic!(\n        \"The crate was compiled without IPC compression. Use `io_ipc_compression` to write compressed IPC.\"\n    )\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-arrow/src/io/ipc/compression.rs#L49-L85","documentation":"`compress_lz4` is a panic stub unless the `io_ipc_compression` cargo feature is enabled. Writing an Arrow IPC file with LZ4 compression requested hits this panic because the build has no LZ4 compressor linked.","triggerScenarios":"Calling the IPC writer with compression set to LZ4 (e.g. `IpcWriteOptions`/encoder with `Compression::Lz4`) in a build without `io_ipc_compression`.","commonSituations":"Enabling IPC compression options at runtime while Cargo features are still default; size-optimization attempts on minimal builds; mismatch between documented API (compression parameter exists regardless of feature) and compiled capabilities.","solutions":["Enable the feature in Cargo.toml: features = [\"io_ipc_compression\"].","Write IPC without compression (set compression to None) if the feature cannot be added.","Feature-gate your own compression-selection code so LZ4/zstd are only requested when the feature is on."],"exampleFix":"// before\nlet options = IpcWriteOptions::try_new(8, false, Compression::Lz4Raw).unwrap(); // panics without feature\n\n// after (with io_ipc_compression enabled)\nlet options = IpcWriteOptions::try_new(8, false, Compression::Lz4Raw).unwrap();\n// or, without the feature:\nlet options = IpcWriteOptions::try_new(8, false, Compression::ZSTD).unwrap_no_comp(); // Compression::None equivalent","handlingStrategy":"validation","validationCode":"// rust: guard compression choice at runtime\nfn pick_compression(requested: Option<Compression>) -> PolarsResult<Compression> {\n    #[cfg(not(feature = \"io_ipc_compression\"))]\n    if matches!(requested, Some(Compression::Lz4Raw) | Some(Compression::ZSTD)) {\n        return Err(PolarsError::ComputeError(\n            \"compression requested but built without io_ipc_compression\".into(),\n        ));\n    }\n    Ok(requested.unwrap_or(Compression::None))\n}","typeGuard":null,"tryCatchPattern":"// rust\nlet result = std::panic::catch_unwind(|| writer.write_batch(&batch));\nmatch result {\n    Ok(v) => v,\n    Err(_) => return Err(\"LZ4 IPC write unsupported in this build; enable io_ipc_compression or write uncompressed\".into()),\n}","preventionTips":["Only expose compression options in builds with io_ipc_compression enabled.","Default IPC writes to uncompressed; make compression opt-in per feature.","Keep dev and CI feature sets aligned with production builds."],"tags":["arrow","ipc","lz4","cargo-feature","panic"],"backgroundTag":"feature-not-enabled","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}