rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.82k stars 2.43k forks source link

Could not read file ... fails `publish` after a long compile time #10773

Open m-kuzmin opened 2 years ago

m-kuzmin commented 2 years ago

Problem

When doing cargo publish the first thing that happens is compiling all the dependencies, but if there is a missing file then the command will fail after so much work was done.

Proposed Solution

It would be nice to have simple checks like missing files be done before compiling dependencies.

Notes

error: failed to read `readme` file for package `ani-tui v0.2.0 (/home/mkr/rust/ani-tui)`

Caused by:
  failed to read `/home/mkr/rust/ani-tui/README.md`

Caused by:
  No such file or directory (os error 2)
weihanglo commented 2 years ago

The validation of the existence of readme and license files is right after the compilation. This may be resolved by putting the logic in front of the compilation, but I am worried that README/License files of some packages might be generated by build.rs. (Should be rare I guess?)

ehuss commented 2 years ago

but I am worried that README/License files of some packages might be generated by build.rs. (Should be rare I guess?)

I wouldn't be too concerned about that. To some degree, Cargo tries to check if the build.rs modifies any files (see here). I think it only checks for source files and not text files, though. It might be worth fingerprinting all the files (unrelated to this issue).

m-kuzmin commented 2 years ago

README/License files of some packages might be generated by build.rs.

Valid. But it's just that little thing I wish worked a little faster.

I dream of a tool that can show me my crate as if it was published so I don't have to push patches for various missing docs and stuff. Yes, we have cargo doc, but sometimes you misspell the Github link or forget that readme.org isn't valid for crates.io. Or you realize something else...