Skip to content

cargo publish should warn if it fails to detect a README #15154

@cbiffle

Description

@cbiffle
Contributor

Problem

I often cargo publish an initial version of a crate without a README... by accident. This is because my naming convention for README files doesn't match what Cargo expects. (I'll open a second bug to ask about whether my convention is common enough to support, but, that's a different matter.)

I always run cargo publish -n first and check for warnings. Cargo is very consistent about warning about missing repository, documentation, license, and other fields, but does not warn if it can't find a README file and none is specified in the Cargo.toml.

Proposed Solution

I'd like to include the readme in the list of fields that cargo publish warns about. (This list appears to be specific to publish, from the source code.) It would be important for this check to be performed after readme autodetection, so that users who have a README named README.md don't get hassled --- only those of us with README.somethingelse.

If there's a real use case for publishing (not packaging!) crates without a README, and people want to do that without a warning, then this might not make sense without a way to suppress the warning.

Notes

In case you're curious, my convention is README.mkdn. But that's not really material for this report.

Activity

added
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-triageStatus: This issue is waiting on initial triage.
on Feb 7, 2025
weihanglo

weihanglo commented on Feb 7, 2025

@weihanglo
Member

According to our current doc, readme is encouraged to be filled in. Cargo would also auto-detect from some paths when missing.

Based on these facts, if we are not going to change the recommendation, I feel like it is reasonable to add README to metadata check.

epage

epage commented on Feb 7, 2025

@epage
Contributor

The initial warning was for description and license (#902, #903). We later extended this to repository, homepage, and documentation (#998, #1053). In all of those discussion, I never saw any talk of README, for or against. Nor am I finding any other issues about this. I'm a bit surprised at that.

Generally, we take the stance that we shouldn't emit warnings without a reasonable way to turn them off until we have #12235. We didn't take that approach with those prior warnings, so maybe thats fine here. One way to soften this is to only warn if the field is None so people can set package.readme = false to disable it.

cbiffle

cbiffle commented on Feb 7, 2025

@cbiffle
ContributorAuthor

Ooooh, I like package.readme = false as a mechanism for explicitly stating that no, thank you, I really don't want to have a readme.

weihanglo

weihanglo commented on Feb 7, 2025

@weihanglo
Member

We didn't take that approach with those prior warnings, so maybe thats fine here

We have --no-metdata on cargo package but not on cargo publish. Wonder if we should also replicate it to cargo publish.

epage

epage commented on Feb 7, 2025

@epage
Contributor

I forget that --no-metadata exists. I feel like #12235 is close enough that we should focus on that.

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

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-packageCommand-publishS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cbiffle@epage@weihanglo

        Issue actions

          `cargo publish` should warn if it fails to detect a README · Issue #15154 · rust-lang/cargo