`cargo install --name`: install with a renamed executable
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Problem
I'm working on a platform where users may be on different versions at a time. To help test with these versions, I'd like to install multiple versions of the binary with cargo install with different names specified at install-time, so that I can use them separately.
Unfortunately, cargo install does not support this at present - the only name configuration can be done in the manifests, which means there's no way to install a different version of the application with a different name.
Aside from the multi-version scheme I've described, it would also be useful for having binaries with different features installed. I work on another project that builds with and without GPU support as a compile-time feature; I'd like to make sure that both versions work equivalently for users without overriding them each time I install.
Proposed Solution
I'd like a --name parameter to be added, so that the resulting binary can be renamed:
cargo install --path cli --name ambient
cargo install --git https://github.com/AmbientRun/Ambient.git --tag v0.2.1 --name ambient-0.2.1
cargo install --git https://github.com/AmbientRun/Ambient.git --rev 123abcdef --name ambient-123abcdef
# ...
where each binary would have the name specified.
I've implemented a hacky version of this in our internal development tool by cargo install-ing to a temporary directory, and then moving the resulting binary into CARGO_HOME/bin with its resulting name: https://github.com/AmbientRun/Ambient/blob/0e3fa3dbc923d4b010a524d9e78a5aa204c79b7c/campfire/src/install.rs#L17-L66
This works, but it's not particularly clean: cargo install warns about the temp directory not being in the PATH, as well as it replacing the existing binary). Official support would make this much nicer.
Notes
This is a successor issue to #11413, as suggested by @weihanglo.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with cargo install's handling of manifest-defined binary names and CARGO_HOME/bin, then compare the temporary-directory workaround linked in campfire/src/install.rs. Verify completion by checking that each shown cargo install form places the requested executable name in CARGO_HOME/bin while preserving normal installation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100