Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Readme file is allowed to not be in the .crate package #14468

Closed
xTachyon opened this issue Aug 30, 2024 · 2 comments
Closed

Readme file is allowed to not be in the .crate package #14468

xTachyon opened this issue Aug 30, 2024 · 2 comments
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@xTachyon
Copy link

Problem

I'm not sure if this is known, it's considered fine, or even if this is the right place, but here we go.

I found this crate that's published as valuable:v0.1.0 that has this line:

readme = "../README.md"

The readme seems to be available on crates.io with no problem, but it's not available in the .crate package.

While this is probably fine for most users, it has issues if you're ever trying to parse the .crate format by yourself, and see the readme.

Steps

No response

Possible Solution(s)

IMHO, paths outside the package directory should not be allowed.

Notes

No response

Version

No response

@xTachyon xTachyon added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Aug 30, 2024
@weihanglo
Copy link
Member

The valuable crate was published a few years ago. Cargo started emitting warning for non-existent README since #12036, and it becomes a hard error since #13921. It's impossible to go back in time and fix that, but any crate published later shouldn't have this issue.

Since the issue is fixed, I am going to close. If you find it happen again, please let us know. Thank you :)

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2024
@epage
Copy link
Contributor

epage commented Aug 30, 2024

Besides the error on non-existent READMEs, cargo package should also copy readmes from outside the package to inside it on cargo package

Err(_) => {
// The file exists somewhere outside of the package.
let file_name = file_path.file_name().unwrap();
if result.iter().any(|ar| ar.rel_path == file_name) {
ws.gctx().shell().warn(&format!(
"{} `{}` appears to be a path outside of the package, \
but there is already a file named `{}` in the root of the package. \
The archived crate will contain the copy in the root of the package. \
Update the {} to point to the path relative \
to the root of the package to remove this warning.",
label,
file_path.display(),
file_name.to_str().unwrap(),
label,
))?;
} else {
result.push(ArchiveFile {
rel_path: PathBuf::from(file_name),
rel_str: file_name.to_str().unwrap().to_string(),
contents: FileContents::OnDisk(abs_file_path),
})
}
}

This was added in #10548 (1.62) to help with inheriting workspace.package.readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants