Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
cbiffle opened this issue Feb 7, 2025 · 5 comments
Open

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

cbiffle opened this issue Feb 7, 2025 · 5 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-package Command-publish S-triage Status: This issue is waiting on initial triage.

Comments

@cbiffle
Copy link
Contributor

cbiffle commented Feb 7, 2025

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.

@cbiffle cbiffle added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Feb 7, 2025
@weihanglo
Copy link
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
Copy link
Contributor

epage commented Feb 7, 2025

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
Copy link
Contributor Author

cbiffle commented Feb 7, 2025

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
Copy link
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
Copy link
Contributor

epage commented Feb 7, 2025

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-package Command-publish S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants