{"record":{"id":"fa464b7d46b1d42f","repo":"rust-lang/cargo","slug":"embedded-manifest-requires-zscript","errorCode":null,"errorMessage":"embedded manifest `{}` requires `-Zscript`","messagePattern":"embedded manifest `(.+?)` requires `-Zscript`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/util/command_prelude.rs","lineNumber":1082,"sourceCode":"            anyhow::bail!(\n                \"manifest path `{}` is a directory but expected a file{suggested_path}\",\n                manifest_path.display()\n            )\n        } else if !path.ends_with(\"Cargo.toml\") && !crate::workspace::parser::is_embedded(&path) {\n            if gctx.cli_unstable().script {\n                anyhow::bail!(\n                    \"the manifest-path must be a path to a Cargo.toml or script file: `{}`\",\n                    path.display()\n                )\n            } else {\n                anyhow::bail!(\n                    \"the manifest-path must be a path to a Cargo.toml file: `{}`\",\n                    path.display()\n                )\n            }\n        }\n        if crate::workspace::parser::is_embedded(&path) && !gctx.cli_unstable().script {\n            anyhow::bail!(\"embedded manifest `{}` requires `-Zscript`\", path.display())\n        }\n        Ok(path)\n    } else {\n        find_root_manifest_for_wd(gctx.cwd())\n    }\n}\n\npub fn get_registry_candidates() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {\n    let gctx = new_gctx_for_completions()?;\n\n    if let Ok(Some(registries)) =\n        gctx.get::<Option<HashMap<String, HashMap<String, String>>>>([\"registries\"])\n    {\n        Ok(registries\n            .keys()\n            .map(|name| clap_complete::CompletionCandidate::new(name.to_owned()))\n            .collect())\n    } else {","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/util/command_prelude.rs#L1064-L1100","documentation":"root_manifest() recognizes the --manifest-path file as an embedded manifest (a single-file .rs package with embedded TOML), but gctx.cli_unstable().script is false. Embedded manifests are gated behind the unstable -Zscript feature.","triggerScenarios":"Passing a single-file .rs script with an embedded manifest to stable Cargo, or nightly Cargo without -Zscript.","commonSituations":"Trying the RFC 3423 single-file-package workflow on stable; a CI job not passing -Zscript.","solutions":["Run on nightly with -Zscript: `cargo +nightly build --manifest-path script.rs -Zscript`.","Convert the single-file package into a normal Cargo project with a Cargo.toml if you must stay on stable."],"exampleFix":"# before\n# cargo build --manifest-path script.rs\n\n# after\n# cargo +nightly build --manifest-path script.rs -Zscript","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn require_script_feature(p: &Path, script_unstable: bool) -> Result<(), String> {\n    if cargo::workspace::parser::is_embedded(p) && !script_unstable {\n        return Err(format!(\"embedded manifest {p:?} requires -Zscript (nightly)\"));\n    }\n    Ok(())\n}","typeGuard":"fn needs_zscript(p: &std::path::Path) -> bool {\n    cargo::workspace::parser::is_embedded(p)\n}","tryCatchPattern":null,"preventionTips":["Detect embedded manifests in your wrapper and automatically inject -Zscript + nightly.","Document that single-file packages are nightly-only."],"tags":["manifest","script","unstable","feature-gate"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}