-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 --reinstall? #2082
Comments
Yeah the discussion on the RFC ended up reaching a point that behaving akin to "make install" was the best way forward for For now this could probably easily be a new |
It would also be nice to have something like |
Is there any reason not to have |
For my CI needs it would be nice to have an option that installs a package if it isn't installed, and otherwise performs an update to the newest version of the package (or does nothing in case it's up-to-date). That way I could more easily make Travis cache the |
@jonas-schievink interesting! I suspect that would be lumped into whatever "install the most recent version" logic would be added as part of this (if added) @oconnor663 there was some pushback on the RFC, but opinions may have perhaps changed since then. |
Now that we have a PR for this (thanks @gkoz!) let's try to drill into some of the initial pushback and see if the landscape has changed here. I believe the main objection to a flag like this is that it was pushing The RFC originally proposed a I'm gonna highlight and cc some of comments on the original RFC that pushed back against functionality like that, but I'm curious if thoughts have changed since? Does usage of
Curious what others think! |
My main comment would merely be confusion as to what the difference between |
I'd argue that adding |
@CamJN
As a result, it fundamentally doesn't support any kind of system-wide dependency handling, package conflict management, etc. That was a design decision explicitly so as to avoid crossing that line. @alexcrichton If you're not doing it based on what you would install, you need to install metadata, which has a number of pitfalls (which I brought up in the other thread, IIRC). If you're doing it based on what you would install, but not from the exact same repository, revision, and build config as the original, you may generate a different list of things you would install, and then fail to remove files that were installed. I would, however, support a proposal to add an
From there, it would be possible to EDIT: Agh, forgot that the metadata thing actually happened, and does get installed. In that case, so long as this doesn't require new metadata, I have no objections as at least it doesn't make it worse. However, the fact that the metadata gets written in-place to a single file ( |
I should probably add that
So the proposed implementation removes the old crate completely if neither |
This does not compute in the presence of |
I don't use My main question is, is there much of a use case for a non-overwriting (I'm not really thinking about the case where two different packages install conflicting files. My guess is that's rare enough / complicated enough that it's fine to require manual intervention.) |
@gkoz: Yeah, see edit. It's been long enough I'd gone fuzzy on some of the details, including that one of my worst-cases (single-file metadata shared among all packages) came to pass. |
My original objection was with the global metadata file. I wanted |
I know it doesn't support those things right now, and honestly I'm glad of it. However I'd be willing to bet that if you asked a bunch of programmers what they would expect cargo to do considering it has a So while limiting this functionality is a good thing from a technical point of view, I think that there are already expectations that cargo will grow to become a full package manager. People might even sympathize with the complexity of what they really want, but I expect a lot of "can I just have this one small super-useful feature" requests. Or people that come looking for functionality they expect and get turned-off if they are told it purposefully doesn't exist. I'm not sure of the histories of rubygems and npm but I imagine they had well scoped goals at the beginning too. There might be something you could do to manage expectations when someone uses |
@Stebalien |
@eternaleye good point. |
Ah yeah sorry to clarify I was thinking that we'd add one of I agree with @eternaleye that we've currently avoided becoming a full-blown package manager, and the intention of Oh right! I realize now that I forgot to add the flag that indicates "don't generate a global manifest". I believe that assuages the concerns you had for packaging? In terms of what we have today, though, it sounds like you're on board that if there's a manifest we may as well use it? @gkoz brings up a good point that I'd personally prefer that a tool warned me somehow that a binary was going to be overwritten, I suspect it could be easy to bite someone by accident if we just overwrote existing files (even if we mentioned we were doing so) |
I agree that we don't want cargo to become a complete package manager, but having Of course I could script this, and I have, but having it built in would be a huge quality of life improvement for me. Or maybe I'm missing something that you naysayers use to make this process easier ;) |
I use multirust, which puts the binaries in version-based locations, such as EDIT: I find it somewhat ironic that Cargo - being a dependency manager for Rust - was so quick to reach for shared mutable state, and it's decidedly suboptimal. If manifest files were non-colliding and per-crate, there would be no need for a flag to disable manifests - any more than such a flag is needed with Haskell. To explain my terms somewhat:
A global manifest file violates this by both reading from and writing to Meanwhile, eliminating the manifests altogether means accepting that In my opinion, manifests aren't the problem - they're just data. Making that data both shared and mutable, on the other hand... |
@mattico, note that there is |
Add `--force` flag to cargo install Close #2082. Adding `--force` (`-f`) instructs cargo to overwrite existing binaries (updating the metadata accordingly). This allows updating crates via `cargo install -f <crate>`. Installation happens in two stages now: binaries are copied into a temporary subdirectory of the destination first, then moved into destination. This should catch some errors earlier. In case of installation error cargo will remove new binaries but won't attempt to undo successful overwrites.
@alexcrichton Should this really have been closed? c.f. #2405 (comment):
|
@alexcrichton Are there any plans on merging cargo-update's functionality into cargo? |
Perhaps eventually! At this point it mostly just needs someone to do the legwork to get it done. |
FWIW I put together a tiny crate which just wraps |
I think this ca be closed by multiple discussions |
Edition 2018 is here, and this issue would be a very nice addition. As suggested, a Also, the default behaviour of not updating an older version of a binary package (e.g. cargo-binutils) and, instead, suggesting force is not user friendly at all. I would say force should be reserved only for some |
Pinging anyone following this issue, I have a proposal to add upgrade functionality to |
Any updates on this? seems like such a basic feature to have |
So. It is no longer a missing feature?. Look at https://rust-cli.github.io/book/tutorial/packaging.html |
I don't see anything at that link that solves the problem of needing |
Now 2021, I still can't find a way to update. |
from https://doc.rust-lang.org/cargo/commands/cargo-install.html |
Oh, thanks for the information. I missed that one. |
TBH, I am confused. I really do not understand how is the "cargo install --update-all" scenario addressed in any way, even after looking at other tickets, including the stabilization one. I simply don't get how can one go from the existing @ehuss was your proposal from #6667 and implementation from #6798 ever targeting that? Or was the stabilization #7560 not covering that part? |
That seems like it needs a separate issue, it wasn't the main point of this issue. For now on unix you can easily turn cargo install --list | grep -v '^ ' | cut -d' ' -f 1 | xargs cargo install |
I'm not saying I'm not able to apply some bash-fu to do this myself, that was not an issue, the point was to make such a thing work for every system, since a tool can end up in the system via For instance, on a system I see there are some tools I have, but it's not clear if they are up to date:
I was thinking since the And the way I was thinking it would have worked was something like this (NOT AN ACTUAL LISTING):
I'll look for a dedicated issue asking the same thing, and create one, if there isn't one. |
Currently
cargo install
won't overwrite existing package if asked to install one. However, this is very inconvenient when you're testing your own binaries (after each change you need to execute two commands instead of one to get a fresh version in PATH) or if you need a binary which frequently changes upstream.What do you think of adding a
--reinstall
key tocargo install
command? When used, it would be equivalent tocargo uninstall <args> && cargo install <args without --reinstall>
, or something like it. I remember it was discussed in the RFC oncargo install
, but I didn't manage to participate in that discussion; maybe it is worth to lay out reasons why it wasn't added eventually and probably reconsider that decision, if there was one.The text was updated successfully, but these errors were encountered: