-
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
Proposal: cargo install
with upgrades
#6667
Comments
Thanks for opening an issue on this @ehuss! This all sounds fantastic to me, and I'm definitely in favor of this proposal. For some of the questions you asked...:
I think this can be bundled with a lot of other parts of this, such as what to do about the environment/compilation flags, linker settings, dependency versions, etc. This all seems like it's developing (what I think at least is) a reasonable policy of "an upgrade is considered as the original source package's code possibly changing or major codegen settings". It only considers the package-being-installed's code which is affected by version number, features, git revs, etc. I think it's reasonable to by default ignore dependency updates because otherwise this command isn't too useful as you'll basically always be reinstalling. Major codegen changes like --debug or not, the target, etc, also seem reasonable to automatically recompile on as they can also affect things like For everything else I think it's reasonable to relegate it to Put another way I feel like ignoring many of these options strikes a good balance between "still a useful command" and "doesn't recompile everything all the time forever". The
Sounds like a good future extension to me :) |
Right now, I expect There needs to be a command that forces build and install; ideally, that command will also skip installing |
We discussed this in the Cargo meeting, and @ehuss clarified several things. Based on those clarifications:
|
I think the name of the command is wrong.
If a user wants to upgrade, then maybe we should introduce
I liked https://crates.io/crates/cargo-ensure-installed's behaviour of "a suitable version", where (IIUC) the version argument is as a semver version requirement spec. Should we do the same? |
No, I explicitly excluded rustc version changes. My thinking is that there are many environmental factors that are not tracked, that generally have little-to-no impact on the behavior of the installed binary (and rustc is one of those). That said, I did include
That is how it works today, and this wouldn't change that.
I'm not a fan of that behavior, because I cannot think of use cases where that is desired behavior, and several where upgrading is beneficial. If one wants to avoid an upgrade, one can test for the existence of the binary first (or lock the version with I did a small survey of other tools to see what their behavior is.
Tools that fail if already installed:
|
If by "use cases" you mean scripting or CI setup use cases, I agree I can't see any for this desired behaviour. But I think it's the right behaviour when a human is interacting with the tool, simply because it matches my expectations of "install". I see So I guess I care more about it not upgrading then the exit code: I'd be ok with it warning and then exiting with code 0. Also, in the case of local sources, i.e. But I'm also not 100% happy the idea of |
On Wed, Feb 27, 2019 at 08:30:43PM -0800, Eric Huss wrote:
> Does this rebuild if you change the cargo or rustc version?
No, I explicitly excluded rustc version changes. My thinking is that there are many environmental factors that are not tracked, that generally have little-to-no impact on the behavior of the installed binary (and rustc is one of those). That said, I did include `rustc` version in the metadata in case we want to use it in the future, or is in some way useful. Generally, `--force` is the intended way to deal with issues like these.
`cargo +nightly install foo` doesn't seem like an unreasonable use case.
Is it really so bad to rebuild *if* the version has changed, which won't
change but every six weeks if you're running stable?
|
The issue there is that if you follow nightly, it would essentially disable the caching since it would appear to change every day. I agree that on stable it would be more reasonable. I just wanted to lean towards a more conservative approach, since you can work around that by using |
Add install-upgrade. This implements the feature described in #6667. Instead of failing when `cargo install` detects a package is already installed, it will upgrade if the versions don't match, or do nothing (exit 0) if it is considered "up-to-date". Closes #6667. Notes: - This feature rejects ambiguous `--version` input (such as `1.0`). This is not required, but seemed like a reasonable time to make the change. - There is a slight change to the output on stable which reports what was installed/replaced. - Added better support for `*` in `--version` (don't show warning).
Implemented in #6798, let's leave this open as a tracking issue |
Oh, I opened a separate tracking issue (#6797) to keep the post-implementation discussion focused there. |
Oops, just kidding then! |
This is a proposal to change the behavior of
cargo install
as discussed at #6595 (comment):The determination of "up to date" is defined as follows:
--version
is specified with an exact version (like1.2.3
), the installed version must be exactly the given version.--version
is specified with a version requirement (like~1.2.3
), it checks the registry for the greatest version matching the requirement (not including pre-release versions), and ensures the installed version is exactly that version.--git
is specified, the installed git hash must match exactly.--path
is specified, it is always reinstalled.cargo install foo
), then it is treated as--version=*
.--bin
,--bins
,--example
,--examples
)--target
Additional clarifications:
cargo install
currently fails..crates.toml Changes
More metadata will need to be stored. Currently it only tracks a mapping of PackageId to the set of binaries it installs. I see two ways to approach migrating to a new format:
1. Switch
.crates.toml
to V2. This will cause older versions of Cargo to fail to install.2. Use a new filename (
.crates2.json
). This will allow older and newer Cargos to coexist.I lean towards the second option, since it would cause less friction, with minimal drawbacks. Additionally, the new file could be designed with forwards compatibility in mind. Specifically, unknown fields for untouched packages should be preserved.
I lean towards changing the format to json. This file is not intended to be user-edited, and toml can be finicky sometimes.
Here's a commented description of the new file format:
It should continue to keep
.crates.toml
up-to-date with its original format.References
cargo install
should check if binary isn't installed/outdated before downloading crate and it shouldn't fail otherwise #6485 — Another upgrade issueUpdate all
I think it might be desirable to have the ability to update all outdated packages. I propose this should be decided upon separately, and should be implemented separately afterwards if it is desired. I think it is desirable to avoid too much complication in one command, so care should be taken. If it can be done with a single flag, that might be acceptable.
One possibility is to have an
--outdated
flag to perform this task. By default, it should update all outdated packages installed from a registry. There are various details to be decided on:--dry-run
?--outdated --list
?)?--outdated
could take some optional arguments, such as--outdated=git
.--outdated=toolchain
?version
is updated?)? What if a package was installed with an explicit--version
?Questions
apt-get --no-upgrade
). My preference is "no" (just to reduce the number of flags), but I am not opposed. There is a workaround ofwhich foo || cargo install foo
.RUSTC
,RUSTC_WRAPPER
,RUSTFLAGS
,CARGO_INCREMENTAL
[target]
settings (rustflags, linker, ar)[build]
settings (rustc, rustflags, incremental)The text was updated successfully, but these errors were encountered: