Skip to content

Commit 3fd69b4

Browse files
Respect UV_INDEX_ rather than UV_HTTP_BASIC_ (#8306)
The docs reference `UV_INDEX_`, but the code actually uses UV_HTTP_BASIC_ as the prefix for environment variable credentials. See PR #7741 Code is at https://github.com/astral-sh/uv/blob/main/crates/uv-static/src/env_vars.rs#L163 ```rust /// Generates the environment variable key for the HTTP Basic authentication username. pub fn http_basic_username(name: &str) -> String { format!("UV_HTTP_BASIC_{name}_USERNAME") } /// Generates the environment variable key for the HTTP Basic authentication password. pub fn http_basic_password(name: &str) -> String { format!("UV_HTTP_BASIC_{name}_PASSWORD") } ``` --------- Co-authored-by: Charlie Marsh <[email protected]>
1 parent c62f8d7 commit 3fd69b4

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

crates/uv-auth/src/credentials.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ impl Credentials {
147147
/// `UV_HTTP_BASIC_PYTORCH_PASSWORD`.
148148
pub fn from_env(name: &str) -> Option<Self> {
149149
let name = name.to_uppercase();
150-
let username = std::env::var(EnvVars::http_basic_username(&name)).ok();
151-
let password = std::env::var(EnvVars::http_basic_password(&name)).ok();
150+
let username = std::env::var(EnvVars::index_username(&name)).ok();
151+
let password = std::env::var(EnvVars::index_password(&name)).ok();
152152
if username.is_none() && password.is_none() {
153153
None
154154
} else {

crates/uv-static/src/env_vars.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ impl EnvVars {
160160
pub const UV_STACK_SIZE: &'static str = "UV_STACK_SIZE";
161161

162162
/// Generates the environment variable key for the HTTP Basic authentication username.
163-
pub fn http_basic_username(name: &str) -> String {
164-
format!("UV_HTTP_BASIC_{name}_USERNAME")
163+
pub fn index_username(name: &str) -> String {
164+
format!("UV_INDEX_{name}_USERNAME")
165165
}
166166

167167
/// Generates the environment variable key for the HTTP Basic authentication password.
168-
pub fn http_basic_password(name: &str) -> String {
169-
format!("UV_HTTP_BASIC_{name}_PASSWORD")
168+
pub fn index_password(name: &str) -> String {
169+
format!("UV_INDEX_{name}_PASSWORD")
170170
}
171171

172172
/// Used to set the uv commit hash at build time via `build.rs`.
@@ -184,12 +184,6 @@ impl EnvVars {
184184
/// Used to set the uv tag distance from head at build time via `build.rs`.
185185
pub const UV_LAST_TAG_DISTANCE: &'static str = "UV_LAST_TAG_DISTANCE";
186186

187-
/// Used in tests for testing providing credentials via environment variables.
188-
pub const UV_HTTP_BASIC_PROXY_USERNAME: &'static str = "UV_HTTP_BASIC_PROXY_USERNAME";
189-
190-
/// Used in tests for testing providing credentials via environment variables.
191-
pub const UV_HTTP_BASIC_PROXY_PASSWORD: &'static str = "UV_HTTP_BASIC_PROXY_PASSWORD";
192-
193187
/// Used to set the spawning/parent interpreter when using --system in the test suite.
194188
pub const UV_INTERNAL__PARENT_INTERPRETER: &'static str = "UV_INTERNAL__PARENT_INTERPRETER";
195189

crates/uv/tests/it/lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6678,8 +6678,8 @@ fn lock_env_credentials() -> Result<()> {
66786678

66796679
// Provide credentials via environment variables.
66806680
uv_snapshot!(context.filters(), context.lock()
6681-
.env(EnvVars::UV_HTTP_BASIC_PROXY_USERNAME, "public")
6682-
.env(EnvVars::UV_HTTP_BASIC_PROXY_PASSWORD, "heron"), @r###"
6681+
.env(EnvVars::index_username("PROXY"), "public")
6682+
.env(EnvVars::index_password("PROXY"), "heron"), @r###"
66836683
success: true
66846684
exit_code: 0
66856685
----- stdout -----

0 commit comments

Comments
 (0)