Skip to content

Commit

Permalink
fix(package): Warn when manifest is not more generally found
Browse files Browse the repository at this point in the history
Being a bit cautious about not turning this into an error since this is
most likely because of case insensitive filesystems.
  • Loading branch information
epage committed Jul 24, 2023
1 parent 55264bc commit 1d9fcb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ fn build_ar_list(
) -> CargoResult<Vec<ArchiveFile>> {
let mut result = Vec::new();
let root = pkg.root();

let mut manifest_found = false;
for src_file in src_files {
let rel_path = src_file.strip_prefix(&root)?.to_path_buf();
check_filename(&rel_path, &mut ws.config().shell())?;
Expand All @@ -242,6 +244,7 @@ fn build_ar_list(
"Cargo.toml" |
// normalize for case insensitive filesystems (like on Windows)
"cargo.toml" => {
manifest_found = true;
result.push(ArchiveFile {
rel_path: PathBuf::from(ORIGINAL_MANIFEST_FILE),
rel_str: ORIGINAL_MANIFEST_FILE.to_string(),
Expand All @@ -267,6 +270,13 @@ fn build_ar_list(
}
}
}
if !manifest_found {
ws.config().shell().warn(&format!(
"no `Cargo.toml` file found when packaging `{}` (note the case of the file name).",
pkg.name()
))?;
}

if pkg.include_lockfile() {
result.push(ArchiveFile {
rel_path: PathBuf::from("Cargo.lock"),
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3069,6 +3069,7 @@ fn no_manifest_found() {
"\
[WARNING] manifest has no documentation[..]
See [..]
[WARNING] no `Cargo.toml` file found when packaging `foo` (note the case of the file name).
[PACKAGING] foo v0.0.1 ([CWD])
[VERIFYING] foo v0.0.1 ([CWD])
[COMPILING] foo v0.0.1 ([CWD][..])
Expand Down

0 comments on commit 1d9fcb2

Please sign in to comment.