Skip to content
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 update --precise without -p flag silently succeeds and runs cargo update #10919

Closed
lopopolo opened this issue Aug 2, 2022 · 3 comments · Fixed by #11349
Closed

cargo update --precise without -p flag silently succeeds and runs cargo update #10919

lopopolo opened this issue Aug 2, 2022 · 3 comments · Fixed by #11349
Assignees
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug Command-update E-easy Experience: Easy

Comments

@lopopolo
Copy link

lopopolo commented Aug 2, 2022

Problem

I tried to use cargo update with the --precise flag to downgrade a dependency without reading the docs.

I tried:

$ cargo update --precise [email protected]
    Updating crates.io index

This succeeded with no error and did not do what I expected.

The docs mention that --precise is meant to be combined with the -p flag:

When used with -p, allows you to specify a specific version number to set the package to. If the package comes from a git repository, this can be a git revision (such as a SHA hash or tag).

Steps

run cargo update --precise [email protected]

Possible Solution(s)

The docs mention that --precise is meant to be combined with the -p flag. If --precise is given without -p, I think this should be an error.

Notes

No response

Version

cargo 1.62.1 (a748cf5a3 2022-06-08)
release: 1.62.1
commit-hash: a748cf5a3e666bc2dcdf54f37adef8ef22196452
commit-date: 2022-06-08
host: x86_64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.79.1 (sys:0.4.51+curl-7.80.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.5.0 [64-bit]
@lopopolo lopopolo added the C-bug Category: bug label Aug 2, 2022
@epage
Copy link
Contributor

epage commented Aug 3, 2022

I'm assuming we'd want to declare the precise argument to requires("package") in clap. While that would be taking a non-error case to an error case, it seems unlikely that someone would be relying on this behavior since its ignored.

@weihanglo
Copy link
Member

weihanglo commented Aug 14, 2022

I'd suggest starting a transition period that warns users it's ignored. Steps to fix might like:

  1. When --precise or --aggressive is present but zero -package given, emit a warning inside update_lockfile(). Tell user that the old behaivour of missing -p that acts as cargo update is deprecated and will soon become a hard error.
  2. Turn it into hard error once the warning hits stable Rust release. That is, the transition period would be three months.
  3. In addition, leverage clap's requires to enforce the hard requirement relationship as epage suggested.

@weihanglo weihanglo added E-easy Experience: Easy A-diagnostics Area: Error and warning messages generated by Cargo itself. E-help-wanted labels Aug 14, 2022
@Rustin170506
Copy link
Member

@rustbot claim

bors added a commit that referenced this issue Aug 17, 2022
Warning when precise or aggressive without -p flag

### What does this PR try to resolve?

ref #10919.

Warning when precise or aggressive without -p flag. It will be a hard error in future.

### How should we test and review this PR?

- Unit test.
@bors bors closed this as completed in 7b9069e Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug Command-update E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants