ripgrep icon indicating copy to clipboard operation
ripgrep copied to clipboard

Support for installing ripgrep with cargo-binstall

Open tomkarw opened this issue 1 year ago • 3 comments

Describe your feature request

cargo-binstall is a way to fetch precompiled binaries without the need to build from source. It is meant to speed up installing new cargo tools.

By default, cargo-binstall will look for GitHub releases artifacts, and ripgrep has these. Unfortunately, cargo-generate requires the version component to conform to v.* pattern, and ripgrep doesn't include the v.

The easiest way to achieve the desired result would be to override this default by adding this to Cargo.toml:

[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/{ version }/{ name }-{ target }-v{ version }.{ archive-format }"

(notice the lack of v in the version component)

If support for cargo-binstall is deemed preferable, I'd be happy to land such PR and test that this solution works.

Alternative

An alternative would be to change the naming conventions for the releases, but I think the above solution is more surgical and less interfering.

tomkarw avatar Sep 01 '22 22:09 tomkarw

I'm not sure I want to encourage more people installing ripgrep through Cargo, but the Cargo.toml lines here look very unobtrusive. So I would be happy to accept a PR for it. And would probably make sense to add cargo binstall instructions to the README.

BurntSushi avatar Sep 01 '22 22:09 BurntSushi

I figured out it would be easier for cargo-binstall to support versions without leading v, rather than go repo by repo and override the default paths. They added it straight away: https://github.com/cargo-bins/cargo-binstall/issues/328!

We can wait till this improvement in cargo-binstall gets released and mention it in the README, I'll prepare a PR for that soon.

tomkarw avatar Sep 02 '22 06:09 tomkarw

Perfect, thanks!

And yeah in retrospect, I do kind of wish I used tags starting with v. But all of my Rust repos follow the same convention and it isn't bad enough to be worth me switching. And switching only some of them would probably drive me nuts. :)

BurntSushi avatar Sep 02 '22 11:09 BurntSushi