hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

Cargo whines about not finding README.md #2553

Open cmskog opened 3 years ago

cmskog commented 3 years ago

I got the following message from cargo recently:

error: failed to parse manifest at /build/hyper-0.13.8.crate/Cargo.toml

Caused by: readme file with name 'README.md' was not found

It seems cargo enforces that a readme file exists if it is included in Cargo.toml.

Obviously, hyper has a README.md file. It is just not included in the crate downloaded from crates.io.

Weirdly, of the crates I have checked, this only seems to apply the hyper crate.

Any idea ?

memoryruins commented 3 years ago

Which rust toolchain are you using? A similar issue was opened last year, but it was a regression in a cargo nightly https://github.com/hyperium/hyper/issues/2231

cmskog commented 3 years ago

Indeed, that might certainly be important for the discussion... For that build, I used a 2020-06-12 nightly.

To reiterate, the flaw is not in hyper(since the crate has the file that is pointed out by package.readme in its Cargo.toml. Which, of course, makes the issue opened in the wrong place. But, perhaps, this place is a good starting point...

And, it is also NOT in cargo. The code in cargo that bails out on a lacking readme file is in commit b0a3cc6b7a42a15937cc63d6b26aa4d25af6ce99. It might be that that commit was later reverted, if it caused too much collateral damage... But, really... That code checks that a file exists, if it is pointed out in Cargo.toml. Is that asking too much ?

The question is rather: Why isn't README.md included in the crate source archive when served from "crates.io" ??? wget -O - 'https://crates.io/api/v1/crates/hyper/0.14.7/download' 2>/dev/null | tar tvz | grep README.md returns nothing.

Is it because of some misplaced optimization effort ? Nope, because, for example, for the serde crate version 1.0.117 we have: wget -O - 'https://crates.io/api/v1/crates/serde/1.0.117/download' 2>/dev/null|tar xzO serde-1.0.117/Cargo.toml|grep readme returns readme = "crates-io.md". And that file exists in the archive: wget -O - 'https://crates.io/api/v1/crates/serde/1.0.117/download' 2>/dev/null|tar tvz|grep crates-io.md returns: -rw-r--r-- 1000/1000 2332 2020-07-13 04:03 serde-1.0.117/crates-io.md

Ideas ?

memoryruins commented 3 years ago

It might be that that commit was later reverted, if it caused too much collateral damage...

Yea I think the regression was fixed a few days later with https://github.com/rust-lang/cargo/pull/8353

Either way, to help avoid issues like that, an option would be to remove the line that specifies README.md since by default (since almost a year ago https://github.com/rust-lang/cargo/pull/8277) cargo checks if a README.md exists if one hasn't been specified, but doesn't error when it doesn't. https://github.com/hyperium/hyper/blob/960a69a5878ede82c56f50ac1444a9e75e885a8f/Cargo.toml#L5

Alternatively/ in addition, the readme file could be added to the include list https://github.com/hyperium/hyper/blob/960a69a5878ede82c56f50ac1444a9e75e885a8f/Cargo.toml#L15-L20