-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo install --name
: install with a renamed executable
#12366
Comments
Thank you for filing this issue and the use cases. Look like a useful feature! There are some open design questions we need to decide (probably more but I am forgetting):
A side note: if you run |
Note that this is not accepted by the Cargo team. We generally discuss the design first, and if we are happy with it then we do an FCP to solicit feedback from the team and the community. @rustbot label +S-needs-design +E-medium +Command-install -S-triage |
Oh wow, yeah - I imagined there might be additional bits of complexity along the way, but you never know just how much!
Yes, good point - there's not always one binary, so a single
Perhaps That seems to strike a good balance between clarity and ease of use. (Is there any precedent for this kind of map-one-target-to-another in the ecosystem?)
Yeah, it seems like extending the format in the long-term is the right call, especially with what you mentioned in the side note. In the short-term, the magic strings could work ( Cargo internals are a bit of a mystery to me (which I consider to be a good thing - the abstraction holds up!), so I probably can't suggest anything else for this in particular. |
Unfortunately it may come into conflict with the other unstable feature We may need to come up with a better design, however, if someone is willing to drive it. My current focus is not on this but feel free to have higher level design discussions here :) |
Maybe, if creating a whole new flag is too complex, having the option to use env. variables like |
@blyxyas, thanks for looking into this. Could you elaborate how a new env can fix the issue? I feel like even using env instead of CLI flag, we still need to figure out these open design issues:
To me, the format of the current installed binary tracker is broken, and may be a blocker. We probably need a way to coordinate with it before moving on. |
I feel like a format like "oldname:newname" or similar is just what we need in this situation! Adding another field would mean more parsing and more storage, not ideal. Whereas a format like "oldname:newname", or even a human-readable format like "oldname as newname" is as simple as getting the two variables with a regex or a While using On the topic of |
Since renaming has a couple gotchas when there are multiple binaries, perhaps simply a |
Perhaps an even better solution (inspired by shared libraries on Linux), what if every binary was installed with its version/rev number postfixed, with a symbolic link pointing to the most recent (released) version? |
The --prefix-name (and/or --suffix-name) would be great, we have some internal crates and sometime the names are quite common like "clean" or "rename" and while those names are ok when running in an container via automation, they can be a bit of a pain when they need to be run manually on a live system. |
Suggestions proposed earlier would be helpful for scenarios I encounter, where projects require specific CLIs at outdated versions to build properly (i.e. wasm-pack, cargo-xtask, wasm-bindgen-cli, etc.) |
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 intoCARGO_HOME/bin
with its resulting name: https://github.com/AmbientRun/Ambient/blob/0e3fa3dbc923d4b010a524d9e78a5aa204c79b7c/campfire/src/install.rs#L17-L66This 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.
The text was updated successfully, but these errors were encountered: