pola-rs/polars · error

Feature `cloud` must be enabled to use globbing patterns…

Error message

Feature `cloud` must be enabled to use globbing patterns with cloud urls.

What it means

expand_paths_hive panics when a globbing pattern (e.g. s3://bucket/data/*.parquet) is used with a cloud URL but the polars 'cloud' feature is disabled, since cloud path expansion requires that feature. The library deliberately aborts instead of silently mis-expanding.

Solutions

  1. Enable the cloud feature: polars = { version = "...", features = ["cloud"] } in Cargo.toml.
  2. Remove the wildcard and pass explicit object paths instead (list files yourself via the cloud SDK).
  3. Use local paths for globbing if cloud access is not actually required.

Example fix

// before
polars = { version = "0.46", features = ["lazy"] }
// after
polars = { version = "0.46", features = ["lazy", "cloud"] }
Defensive patterns

Strategy: validation

Validate before calling

fn is_cloud_glob(path: &str) -> bool {
    (path.starts_with("s3://") || path.starts_with("gs://") || path.starts_with("az://") || path.starts_with("azure://"))
        && path.chars().any(|c| c == '*' || c == '?' || c == '[')
}
assert!(!paths.iter().any(is_cloud_glob), "cloud globbing needs the 'cloud' feature");

Try / catch

// It's a panic, not a Result; pre-validate inputs before calling expand_paths
if is_cloud_glob(&url) {
    // list objects via cloud SDK instead, or compile with the cloud feature
}

Prevention

When it happens

Trigger: Calling expand_paths / expand_paths_hive (directly or via scan/read functions) with a glob pattern in a cloud scheme URL (s3://, gs://, azure://...) on a polars build compiled without feature = "cloud".

Common situations: Using prebuilt polars wheels/binaries without the cloud feature while scanning wildcards on S3/GCS/Azure; upgrading polars and losing the feature flag in Cargo.toml.

Related errors


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

Appendix: source

Thrown at crates/polars-io/src/path_utils/mod.rs:541

                        first_path_has_scheme,
                    )
                    .await?;
                    for (p, size) in paths {
                        if let Some(size) = size {
                            sizes_by_path.insert(p.clone(), size);
                        }
                        out_paths.push(p);
                    }
                    hive_idx_tracker.update(expand_start_idx, path_idx)?;
                };

                if let Some(mut_slice) = out_paths.paths.get_mut(sort_start_idx..) {
                    <[PlRefPath]>::sort_unstable(mut_slice);
                }
            }
        }
        #[cfg(not(feature = "cloud"))]
        panic!("Feature `cloud` must be enabled to use globbing patterns with cloud urls.")
    } else {
        let mut stack: VecDeque<Cow<'_, Path>> = VecDeque::new();
        let mut paths_scratch: Vec<PathBuf> = vec![];

        for (path_idx, path) in paths.iter().enumerate() {
            stack.clear();
            let sort_start_idx = out_paths.paths.len();

            if path.as_std_path().is_dir() {
                let i = path.as_str().len();

                hive_idx_tracker.update(i, path_idx)?;

                stack.push_back(Cow::Borrowed(path.as_std_path()));

                while let Some(dir) = stack.pop_front() {
                    let mut last_err = Ok(());

View on GitHub (pinned to fe841f959e)