rust-lang/cargo · error · anyhow::Error

cannot publish with `open-namespaces`

Error message

cannot publish with `open-namespaces`

What it means

Error "cannot publish with `open-namespaces`" thrown in rust-lang/cargo.

Source

Thrown at src/workspace/parser/mod.rs:3016

/// Prepares the manifest for publishing.
// - Path and git components of dependency specifications are removed.
// - License path is updated to point within the package.
fn prepare_toml_for_publish(
    me: &manifest::TomlManifest,
    ws: &Workspace<'_>,
    package_root: &Path,
    packaged_files: Option<&[PathBuf]>,
) -> CargoResult<manifest::TomlManifest> {
    let gctx = ws.gctx();

    if me
        .cargo_features
        .iter()
        .flat_map(|f| f.iter())
        .any(|f| f == "open-namespaces")
    {
        anyhow::bail!("cannot publish with `open-namespaces`")
    }

    let mut package = me.package().unwrap().clone();
    package.workspace = None;
    // Validates if build script file is included in package. If not, warn and ignore.
    if let Some(custom_build_scripts) = package.normalized_build().expect("previously normalized") {
        let mut included_scripts = Vec::new();
        for script in custom_build_scripts {
            let path = Path::new(script).to_path_buf();
            let included = packaged_files.map(|i| i.contains(&path)).unwrap_or(true);
            if included {
                let path = path
                    .into_os_string()
                    .into_string()
                    .map_err(|_err| anyhow::format_err!("non-UTF8 `package.build`"))?;
                let path = normalize_path_string_sep(path);
                included_scripts.push(path);
            } else {

View on GitHub (pinned to 0e07a15537)

Solutions

  1. Remove `open-namespaces` from the manifest before publishing; it is only supported on nightly for local development.
  2. If you need namespace features, build with `-Zopen-namespaces` locally but publish without the flag.

When it happens

Trigger: Thrown at src/workspace/parser/mod.rs:3016 when the library encounters an invalid state.

Common situations: Occurs when `cargo publish` is run on a package whose manifest enables the unstable `open-namespaces` feature. Avoid enabling `open-namespaces` for packages intended to be published, or remove the feature before publishing.


AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06). Data as JSON: /data/errors/350219ce68a6a3e0.json. Report an issue: GitHub.