cargo-bins / cargo-binstall

Binary installation for rust projects
GNU General Public License v3.0
1.41k stars 51 forks source link

When a package's repo ends with .git cargo-binstall fails to download the files from GitHub #1801

Open kristof-mattei opened 1 week ago

kristof-mattei commented 1 week ago

Example:

https://crates.io/crates/cargo-spellcheck

Repository is set to https://github.com/drahnr/cargo-spellcheck.git

While GitHub itself redirects to the non-.git version, the GH Rest and Graph API do not normalize a repo that is ending in .git to the non-.git ending version.

This causes mismatches which make cargo-binstall unable to find the downloads, and resort to fetching source + compile.

Fails:

cargo-binstall cargo-spellcheck --target x86_64-unknown-linux-gnu --pkg-url "{ repo }/releases/download/v{ version }/{ name }-v{
version }-{ target }" --pkg-fmt bin --verbose --strategies crate-meta-data --dry-run

However when we hardcode the URL it works:

cargo-binstall cargo-spellcheck --target x86_64-unknown-linux-gnu --pkg-url "https://github.com/drahnr/cargo-spellcheck.git/releases/download/v{ version }/{ name }-v{
version }-{ target }" --pkg-fmt bin --verbose --strategies crate-meta-data --dry-run
NobodyXu commented 1 week ago

Thanks for reporting!

Adding a strip here would fix it

https://github.com/cargo-bins/cargo-binstall/blob/76814e4e8feaede87d8d112a4fad519d8eeaf81d/crates/binstalk-fetchers/src/lib.rs#L195

I don't have time to create a PR now though I do have time to review one, so if you are willing to open one, I can review and cut a new release to fix this!

kristof-mattei commented 1 week ago

Thanks for reporting!

Adding a strip here would fix it

https://github.com/cargo-bins/cargo-binstall/blob/76814e4e8feaede87d8d112a4fad519d8eeaf81d/crates/binstalk-fetchers/src/lib.rs#L195

I don't have time to create a PR now though I do have time to review one, so if you are willing to open one, I can review and cut a new release to fix this!

Roger, I'll make one tomorrow.

kristof-mattei commented 1 week ago

Hi @NobodyXu I've added 2 PRs: #1803 & #1804. I prefer #1803, as that function really goes though the GitHub API and normalizes the string as per GitHub's expectations, whereas #1804 doesn't, it just patches what our understanding of the specs are.

But #1803 is hard to test, as the test requires internet connection.

Would love to hear your feedback.