Skip to content

Cargo whines about not finding README.md #2553

Open

Description

@cmskog

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 ?

Activity

  1. memoryruins commented on May 16, 2021

    @memoryruins
    Contributor

    Which rust toolchain are you using? A similar issue was opened last year, but it was a regression in a cargo nightly #2231

  2. cmskog commented on May 17, 2021

    @cmskog
    Author

    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 ?

  3. memoryruins commented on May 17, 2021

    @memoryruins
    Contributor

    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 rust-lang/cargo#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 rust-lang/cargo#8277) cargo checks if a README.md exists if one hasn't been specified, but doesn't error when it doesn't.

    readme = "README.md"

    Alternatively/ in addition, the readme file could be added to the include list

    hyper/Cargo.toml

    Lines 15 to 20 in 960a69a

    include = [
    "Cargo.toml",
    "LICENSE",
    "src/**/*",
    #"build.rs",
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions