rust-lang/cargo · error · anyhow::Error
{manifest_key_name} `{}` does not appear to exist{}.
Error message
{manifest_key_name} `{}` does not appear to exist{}.
Please update the {manifest_key_name} setting in the manifest at `{}`. What it means
During packaging, Cargo validates manifest path fields (`license-file` and `readme`) by joining them to the package root and checking is_file(). If the referenced file is missing, error_on_nonexistent_file pushes a message (naming the manifest key, the path, and the manifest location) into invalid_manifest_field; once all checks finish, if that buffer is non-empty it is thrown as a single aggregated anyhow error at cargo_package/mod.rs:621.
Source
Thrown at src/ops/cargo_package/mod.rs:621
&pkg,
&license_path,
"license-file",
&mut invalid_manifest_field,
);
}
}
if let Some(readme) = &pkg.manifest().metadata().readme {
let readme_path = Path::new(readme);
let abs_file_path = paths::normalize_path(&pkg.root().join(readme_path));
if abs_file_path.is_file() {
check_for_file_and_add("readme", readme_path, abs_file_path, pkg, &mut result, ws)?;
} else {
error_on_nonexistent_file(&pkg, &readme_path, "readme", &mut invalid_manifest_field);
}
}
if !invalid_manifest_field.is_empty() {
return Err(anyhow::anyhow!(invalid_manifest_field.join("\n")));
}
for t in pkg
.manifest()
.targets()
.iter()
.filter(|t| t.is_custom_build())
{
if let Some(custom_build_path) = t.src_path().path() {
let abs_custom_build_path = paths::normalize_path(&pkg.root().join(custom_build_path));
if !abs_custom_build_path.is_file() || !abs_custom_build_path.starts_with(pkg.root()) {
error_custom_build_file_not_in_package(pkg, &abs_custom_build_path, t)?;
}
}
}
result.sort_unstable_by(|a, b| a.rel_path.cmp(&b.rel_path));
View on GitHub (pinned to 0e07a15537)
Solutions
- Create or restore the referenced file (e.g. `touch README.md` or restore LICENSE)
- Update Cargo.toml so `license-file`/`readme` points to the correct existing path
- Remove the field from Cargo.toml entirely if the file is not needed
- Ensure the path is relative to the package root and the file is committed (not gitignored)
Example fix
# before # Cargo.toml: readme = "README.md" (file missing) cargo package # -> error # after (option A): create the file echo '# mycrate' > README.md # after (option B): fix the path # readme = "docs/README.md" # after (option C): drop the field # (remove the readme = line)
Defensive patterns
Strategy: validation
Validate before calling
use std::path::{Path, PathBuf};
fn validate_manifest_paths(root: &Path, fields: &[(&str, &str)]) -> Result<(), String> {
for (key, val) in fields {
let abs = root.join(val);
if !abs.is_file() {
return Err(format!("{key} `{val}` does not exist at {}", abs.display()));
}
}
Ok(())
}
validate_manifest_paths(root, &[("readme", readme), ("license-file", license)])?; Type guard
import { existsSync } from 'fs';
import { join } from 'path';
function manifestPathsExist(root: string, fields: Record<string,string>): boolean {
return Object.entries(fields).every(([_, rel]) => existsSync(join(root, rel)));
} Prevention
- Run `cargo package --list` to surface missing readme/license-file before publishing
- Add a CI step that asserts Cargo.toml path fields resolve to real files
- When renaming/deleting README/LICENSE, update Cargo.toml in the same commit
When it happens
Trigger: `cargo package` with `license-file = "LICENSE"` when no LICENSE file exists, or `readme = "README.md"` after the README was deleted/renamed. Also fires if the path is relative but resolves outside the package.
Common situations: Deleted the README but left `readme = ` in Cargo.toml; renamed LICENSE-MIT to LICENSE without updating the manifest; path typos; CI packaging a sparse checkout that omitted the license/readme; relative paths that escape the package root.
Related errors
- could not compile due to {error_count} previous target resol
- {}This may cause issue during packaging, as modules resoluti
- `resolver` setting `{}` is not valid, valid options are "1",
- '{}' is not a valid artifact specifier
- Cannot specify both 'bin' and 'bin:<name>' binary artifacts,
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/a57572a1b715dcfc.json.
Report an issue: GitHub.