{"id":"37c906adc0e694bc","repo":"rust-lang/cargo","slug":"manifest-path-is-absolute","errorCode":null,"errorMessage":"manifest path is absolute","messagePattern":"manifest path is absolute","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_update.rs","lineNumber":472,"sourceCode":"    }\n\n    let mut any_file_has_changed = false;\n\n    let items = std::iter::once((ws.root_manifest(), ws.unstable_features()))\n        .chain(ws.members().map(|member| {\n            (\n                member.manifest_path(),\n                member.manifest().unstable_features(),\n            )\n        }))\n        .collect::<Vec<_>>();\n\n    for (manifest_path, unstable_features) in items {\n        trace!(\"updating TOML manifest at `{manifest_path:?}` with upgraded dependencies\");\n\n        let crate_root = manifest_path\n            .parent()\n            .expect(\"manifest path is absolute\")\n            .to_owned();\n\n        let mut local_manifest = LocalManifest::try_new(&manifest_path)?;\n        let mut manifest_has_changed = false;\n\n        for dep_table in local_manifest.get_dependency_tables_mut() {\n            for (mut dep_key, dep_item) in dep_table.iter_mut() {\n                let dep_key_str = dep_key.get();\n                let dependency = crate::workspace::editor::dependency::Dependency::from_toml(\n                    ws.gctx(),\n                    ws.root(),\n                    &manifest_path,\n                    unstable_features,\n                    dep_key_str,\n                    dep_item,\n                )?;\n                let name = &dependency.name;\n","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_update.rs#L454-L490","documentation":"`write_manifest_upgrades` calls `manifest_path.parent().expect(\"manifest path is absolute\")`. `Path::parent()` returns `None` only when the path has no parent component (e.g. `/`, `C:\\`, or an empty path) — not for ordinary absolute paths. The message is misleading: the real precondition is that the manifest path is not a filesystem root.","triggerScenarios":"Fires if a workspace member's `manifest_path` is a root-level path with no parent — e.g. literally `/Cargo.toml` is not possible because `/Cargo.toml`'s parent is `/`, but a path equal to `/` or `` itself would. Realistically only via a malformed manifest path constructed programmatically or a virtual manifest sitting at the filesystem root.","commonSituations":"Extremely unlikely in practice; would require a manifest path that `parent()` cannot slice. Encountered in tests or tooling that passes a synthetic/empty path to the upgrade writer. End users running `cargo update` never hit this.","solutions":["Report a cargo bug if `cargo update` triggers it; include the workspace layout and any `[workspace]` member glob patterns.","Check for unusual member paths (`path = \"/\"` or a member glob resolving to a root) in `Cargo.toml`.","If patching cargo, replace the `expect` with a `bail!` describing the offending path."],"exampleFix":"// before\nlet crate_root = manifest_path.parent().expect(\"manifest path is absolute\").to_owned();\n\n// after\nlet crate_root = manifest_path.parent()\n    .ok_or_else(|| anyhow::format_err!(\n        \"manifest path `{}` has no parent directory\", manifest_path.display()))?\n    .to_owned();","handlingStrategy":"validation","validationCode":"// Ensure every workspace manifest path has a parent before upgrade writing.\nfor (mp, _) in &items {\n    if mp.parent().is_none() {\n        return Err(anyhow!(\"manifest path `{}` has no parent dir\", mp.display()));\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid workspace member paths that resolve to filesystem roots.","Validate `[workspace.members]` glob results before relying on them."],"tags":["cargo","panic","invariant","cargo-update","filesystem","manifest","rust"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}