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

Error message with credential-process and a token is confusing. #12320

Closed
ehuss opened this issue Jun 29, 2023 · 3 comments
Closed

Error message with credential-process and a token is confusing. #12320

ehuss opened this issue Jun 29, 2023 · 3 comments
Assignees
Labels
A-credential-provider Area: credential provider for storing and retreiving credentials A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jun 29, 2023

Problem

If you are currently logged in to a registry using the typical token setting in credentials.toml, and you add a configuration for registry.credential-process, the error message when running cargo login is a little confusing:

error: both `token` and `credential-process` were specified in the config.
Only one of these values may be set, remove one or the other to proceed.

If a user is not following the instructions to the letter, or is not intimately familiar with cargo's auth setup, this doesn't really tell you what to do to fix the error.

Steps

  1. Do a normal login: cargo login
  2. Set up a credential process in config.toml:
    [registry]
    credential-process = "cargo:1password"
  3. Run cargo login -Zcredential-process

Possible Solution(s)

The error message could be a little clearer about what it means about a "token...in the config". A user may not know or equate that a legacy cargo login means that a "token is in the config". I would probably completely reword this error message to explain that they are logged in via the old mechanism, and that needs to be removed before using credential-process (though I'm not sure how to phrase "old mechanism").

I think the message could also include some instructions on how to fix it (such as running cargo logout).

Notes

No response

Version

cargo 1.72.0-nightly (03bc66b55 2023-06-23)
release: 1.72.0-nightly
commit-hash: 03bc66b55c290324bd46eb22e369c8fae1908f91
commit-date: 2023-06-23
host: aarch64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.1.2-DEV (sys:0.4.63+curl-8.1.2 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Ubuntu 22.04 (jammy) [64-bit]
@ehuss ehuss added C-bug Category: bug A-diagnostics Area: Error and warning messages generated by Cargo itself. S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. A-credential-provider Area: credential provider for storing and retreiving credentials labels Jun 29, 2023
@chansuke
Copy link
Contributor

@rustbot claim

@arlosi
Copy link
Contributor

arlosi commented Jul 21, 2023

@chansuke FYI I'm making significant changes to how -Zcredential-process works in #12334.

@ehuss
Copy link
Contributor Author

ehuss commented Jul 22, 2023

I'm going to close as resolved by #12334. The new behavior is to issue a warning that looks like:

warning: registry `crates-io` has a token configured in /Users/eric/.cargo/credentials.toml that will be ignored because the `cargo:token` credential provider is not listed in `registry.global-credential-providers`

This points the user to the file where the token is, and explains why it is not being used. Hopefully that provides enough information for the user to figure out what to do, but we can definitely iterate on it more if it isn't clear enough.

@ehuss ehuss closed this as completed Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-credential-provider Area: credential provider for storing and retreiving credentials A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.
Projects
None yet
Development

No branches or pull requests

3 participants