From 0a638e655c19fea6b351f6fb180ea503b164d63e Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Wed, 6 Sep 2023 14:27:35 -0500 Subject: [PATCH] remove environment variable note from AuthorizationError --- src/cargo/util/auth/mod.rs | 12 +++--------- tests/testsuite/alt_registry.rs | 12 ++++-------- tests/testsuite/credential_process.rs | 3 --- tests/testsuite/registry.rs | 4 ---- tests/testsuite/registry_auth.rs | 7 ++----- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index 4e7ae65a0d8..3edc9030fa9 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -2,7 +2,7 @@ use crate::{ sources::CRATES_IO_REGISTRY, - util::{config::ConfigKey, CanonicalUrl, CargoResult, Config, IntoUrl}, + util::{CanonicalUrl, CargoResult, Config, IntoUrl}, }; use anyhow::{bail, Context as _}; use cargo_credential::{ @@ -372,19 +372,13 @@ impl fmt::Display for AuthorizationError { } else { "" }; - write!( - f, - "{}, please run `cargo login{args}`\nor use environment variable CARGO_REGISTRY_TOKEN", - self.reason - ) + write!(f, "{}, please run `cargo login{args}`", self.reason) } else if let Some(name) = self.sid.alt_registry_key() { - let key = ConfigKey::from_str(&format!("registries.{name}.token")); write!( f, - "{} for `{}`, please run `cargo login --registry {name}`\nor use environment variable {}", + "{} for `{}`, please run `cargo login --registry {name}`", self.reason, self.sid.display_registry_name(), - key.as_env_key(), ) } else if self.reason == AuthorizationErrorReason::TokenMissing { write!( diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index 91157cd5327..788b82177a9 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -432,8 +432,7 @@ fn block_publish_due_to_no_token() { .with_stderr( "\ [UPDATING] `alternative` index -error: no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", +error: no token found for `alternative`, please run `cargo login --registry alternative`", ) .run(); } @@ -459,8 +458,7 @@ fn cargo_registries_crates_io_protocol() { .with_stderr( "\ [UPDATING] `alternative` index -error: no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", +error: no token found for `alternative`, please run `cargo login --registry alternative`", ) .run(); } @@ -1531,8 +1529,7 @@ fn warn_for_unused_fields() { "\ [UPDATING] `alternative` index [WARNING] unused config key `registries.alternative.unexpected-field` in `[..]config.toml` -[ERROR] no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", +[ERROR] no token found for `alternative`, please run `cargo login --registry alternative`", ) .run(); @@ -1542,8 +1539,7 @@ or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", "\ [UPDATING] crates.io index [WARNING] unused config key `registry.unexpected-field` in `[..]config.toml` -[ERROR] no token found, please run `cargo login` -or use environment variable CARGO_REGISTRY_TOKEN", +[ERROR] no token found, please run `cargo login`", ) .run(); } diff --git a/tests/testsuite/credential_process.rs b/tests/testsuite/credential_process.rs index 222f6b97835..64b08876655 100644 --- a/tests/testsuite/credential_process.rs +++ b/tests/testsuite/credential_process.rs @@ -38,7 +38,6 @@ fn gated() { "\ [UPDATING] [..] [ERROR] no token found, please run `cargo login` -or use environment variable CARGO_REGISTRY_TOKEN ", ) .run(); @@ -58,7 +57,6 @@ or use environment variable CARGO_REGISTRY_TOKEN "\ [UPDATING] [..] [ERROR] no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN ", ) .run(); @@ -354,7 +352,6 @@ fn all_not_found() { Caused by: no token found, please run `cargo login` - or use environment variable CARGO_REGISTRY_TOKEN "#, ) .run(); diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 0569249e07f..6084805134e 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -3224,7 +3224,6 @@ fn default_auth_error() { "\ [UPDATING] crates.io index error: no token found, please run `cargo login` -or use environment variable CARGO_REGISTRY_TOKEN ", ) .with_status(101) @@ -3236,7 +3235,6 @@ or use environment variable CARGO_REGISTRY_TOKEN "\ [UPDATING] `alternative` index error: no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN ", ) .with_status(101) @@ -3258,7 +3256,6 @@ or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN "\ [UPDATING] `alternative` index error: no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN ", ) .with_status(101) @@ -3270,7 +3267,6 @@ or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN "\ [UPDATING] crates.io index error: no token found, please run `cargo login --registry crates-io` -or use environment variable CARGO_REGISTRY_TOKEN ", ) .with_status(101) diff --git a/tests/testsuite/registry_auth.rs b/tests/testsuite/registry_auth.rs index 9f127669df3..c5e24460331 100644 --- a/tests/testsuite/registry_auth.rs +++ b/tests/testsuite/registry_auth.rs @@ -247,8 +247,7 @@ fn missing_token() { [ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..])` Caused by: - no token found for `alternative`, please run `cargo login --registry alternative` - or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", + no token found for `alternative`, please run `cargo login --registry alternative`", ) .run(); } @@ -273,8 +272,7 @@ Caused by: unable to get packages from source Caused by: - no token found for `alternative`, please run `cargo login --registry alternative` - or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", + no token found for `alternative`, please run `cargo login --registry alternative`", ) .run(); } @@ -299,7 +297,6 @@ fn incorrect_token() { Caused by: token rejected for `alternative`, please run `cargo login --registry alternative` - or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN Caused by: failed to get successful HTTP response from `http://[..]/index/config.json`, got 401