rust-lang/cargo · error
manifest path is absolute
Error message
manifest path is absolute
What it means
`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.
Source
Thrown at src/ops/cargo_update.rs:472
}
let mut any_file_has_changed = false;
let items = std::iter::once((ws.root_manifest(), ws.unstable_features()))
.chain(ws.members().map(|member| {
(
member.manifest_path(),
member.manifest().unstable_features(),
)
}))
.collect::<Vec<_>>();
for (manifest_path, unstable_features) in items {
trace!("updating TOML manifest at `{manifest_path:?}` with upgraded dependencies");
let crate_root = manifest_path
.parent()
.expect("manifest path is absolute")
.to_owned();
let mut local_manifest = LocalManifest::try_new(&manifest_path)?;
let mut manifest_has_changed = false;
for dep_table in local_manifest.get_dependency_tables_mut() {
for (mut dep_key, dep_item) in dep_table.iter_mut() {
let dep_key_str = dep_key.get();
let dependency = crate::workspace::editor::dependency::Dependency::from_toml(
ws.gctx(),
ws.root(),
&manifest_path,
unstable_features,
dep_key_str,
dep_item,
)?;
let name = &dependency.name;
View on GitHub (pinned to 0e07a15537)
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.
Example fix
// before
let crate_root = manifest_path.parent().expect("manifest path is absolute").to_owned();
// after
let crate_root = manifest_path.parent()
.ok_or_else(|| anyhow::format_err!(
"manifest path `{}` has no parent directory", manifest_path.display()))?
.to_owned(); Defensive patterns
Strategy: validation
Validate before calling
// Ensure every workspace manifest path has a parent before upgrade writing.
for (mp, _) in &items {
if mp.parent().is_none() {
return Err(anyhow!("manifest path `{}` has no parent dir", mp.display()));
}
} Prevention
- Avoid workspace member paths that resolve to filesystem roots.
- Validate `[workspace.members]` glob results before relying on them.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/37c906adc0e694bc.json.
Report an issue: GitHub.