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

Wrong readme link resolution for relative paths with workspace readme #9927

Closed
beeb opened this issue Nov 14, 2024 · 2 comments
Closed

Wrong readme link resolution for relative paths with workspace readme #9927

beeb opened this issue Nov 14, 2024 · 2 comments

Comments

@beeb
Copy link

beeb commented Nov 14, 2024

Current Behavior

Consider a repository at https://github.com/foo/bar.git.

The README.md file at the root contains the following:

See [this file](./thisfile.md)

The root Cargo.toml contains:

[workspace]
members = ["crates/mycrate"]
resolver = "2"

[workspace.package]
readme = "./README.md"

The crates/mycrate/Cargo.toml:

[package]
# ...
readme.workspace = true

In that case, the README on crates.io will resolve the link to https://github.com/foo/bar/blob/HEAD/crates/mycrate/thisfile.md.

Expected Behavior

The link in the README on crates.io should resolve to https://github.com/foo/bar/blob/HEAD/thisfile.md.

Steps To Reproduce

See setup in the "Current Behavior" section.

Environment

  • Browser: N/A
  • OS: N/A

Anything else?

The same problem appears with relative images.

@Turbo87
Copy link
Member

Turbo87 commented Nov 14, 2024

this is basically the same issue as #9886. since cargo rewrites the Cargo.toml file to readme = "README.md" there is unfortunately not much we can do on our side. my best advice is to not use relative links/URLs if you rely on a README file that is not inside the crate folder.

@beeb
Copy link
Author

beeb commented Nov 14, 2024

Oh I see. Thanks for the clarification. This is unfortunate, maybe cargo should rewrite to ../../README.md instead. Is there an open issue on the cargo side for this?

EDIT: Ah I see, cargo first copies the README.md into the root of the crate (alongside the Cargo.toml of the crate) before rewriting the path.

@beeb beeb closed this as completed Nov 14, 2024
beeb added a commit to beeb/soldeer that referenced this issue Nov 14, 2024
Due to how cargo packages crates from a workspace, the relative paths used in the readme do not work when visiting crates.io (see rust-lang/crates.io#9927).

This is easily fixed by using absolute URLs into the link.
beeb added a commit to mario-eth/soldeer that referenced this issue Nov 14, 2024
Due to how cargo packages crates from a workspace, the relative paths used in the readme do not work when visiting crates.io (see rust-lang/crates.io#9927).

This is easily fixed by using absolute URLs into the link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants