Skip to content

cargo install --name: install with a renamed executable #12366

Open
@philpax

Description

@philpax

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-installE-mediumExperience: MediumS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions