-
Notifications
You must be signed in to change notification settings - Fork 2.9k
cargo install --name: install with a renamed executable #12366
Copy link
Copy link
Open
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-installE-mediumExperience: MediumExperience: MediumS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-installE-mediumExperience: MediumExperience: MediumS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 installwith different names specified at install-time, so that I can use them separately.Unfortunately,
cargo installdoes 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
--nameparameter 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 intoCARGO_HOME/binwith its resulting name: https://github.com/AmbientRun/Ambient/blob/0e3fa3dbc923d4b010a524d9e78a5aa204c79b7c/campfire/src/install.rs#L17-L66This works, but it's not particularly clean:
cargo installwarns 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.