pola-rs/polars · error

activate ' ' feature

Error message

activate '{}' feature

What it means

This is the implementation of polars' feature-gating macro (feature_gated!-style). It compiles the gated content only when ALL listed cargo features are enabled; otherwise it emits panic!("activate '{}' feature", ...). The panic text is a template — the actual message names the missing features. It means a code path was reached that requires cargo features the build does not have.

Solutions

  1. Read the full panic message to get the exact feature list requested
  2. Add the named features to the polars dependency in Cargo.toml
  3. Check unified feature resolution with `cargo tree -e features` — a crate with default-features = false may be stripping what you enabled
  4. If the feature cannot be enabled (e.g. size constraints), route around the gated API at runtime by branching on your own configuration before calling it

Example fix

// before
polars = { version = "0.46", default-features = false, features = ["lazy"] }
// after
polars = { version = "0.46", default-features = false, features = ["lazy", "dtype-u8", "dtype-i8"] }
Defensive patterns

Strategy: validation

Validate before calling

// build-time check
fn main() {
    // the panic message names the missing features; ensure them in Cargo.toml
}
// or gate your own code:
#[cfg(not(feature = "polars/dtype-duration"))]
compile_error!("enable required polars features");

Prevention

When it happens

Trigger: Calling any polars API wrapped in this macro (e.g. dtype-specific or algorithm-specific functionality) without the corresponding cargo feature(s) enabled.

Common situations: Default-features-off builds; picking features piecemeal from docs; a dependency enabling a polars API path but not the matching feature; upgrading polars where features were split or renamed.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/faa3e8ca525e2b27. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-error/src/lib.rs:677

}

#[inline]
#[cold]
#[must_use]
pub fn to_compute_err(err: impl Display) -> PolarsError {
    PolarsError::ComputeError(err.to_string().into())
}

#[macro_export]
macro_rules! feature_gated {
    ($($feature:literal);*, $content:expr) => {{
        #[cfg(all($(feature = $feature),*))]
        {
            $content
        }
        #[cfg(not(all($(feature = $feature),*)))]
        {
            panic!("activate '{}' feature", concat!($($feature, ", "),*))
        }
    }};
}

// Not public, referenced by macros only.
#[doc(hidden)]
pub mod __private {
    #[doc(hidden)]
    #[inline]
    #[cold]
    #[must_use]
    pub const fn must_use(error: crate::PolarsError) -> crate::PolarsError {
        error
    }

    pub const fn has_brace(s: &str) -> bool {
        let bytes = s.as_bytes();
        let mut i: usize = 0;

View on GitHub (pinned to fe841f959e)