Skip to content

Commit ede47c0

Browse files
Document .netrc environment variable and path (#8511)
## Summary Closes #8482.
1 parent dff5077 commit ede47c0

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

crates/uv-auth/src/middleware.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ impl AuthMiddleware {
7171
}
7272
}
7373

74-
/// Configure the [`netrc::Netrc`] credential file to use.
74+
/// Configure the [`Netrc`] credential file to use.
7575
///
7676
/// `None` disables authentication via netrc.
7777
#[must_use]
78-
pub fn with_netrc(mut self, netrc: Option<netrc::Netrc>) -> Self {
78+
pub fn with_netrc(mut self, netrc: Option<Netrc>) -> Self {
7979
self.netrc = if let Some(netrc) = netrc {
8080
NetrcMode::Enabled(netrc)
8181
} else {

docs/configuration/authentication.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ uv supports credentials over HTTP when querying package registries.
3535
Authentication can come from the following sources, in order of precedence:
3636

3737
- The URL, e.g., `https://<user>:<password>@<hostname>/...`
38-
- A [`netrc`](https://everything.curl.dev/usingcurl/netrc) configuration file
38+
- A [`.netrc`](https://everything.curl.dev/usingcurl/netrc) configuration file
3939
- A [keyring](https://github.com/jaraco/keyring) provider (requires opt-in)
4040

4141
If authentication is found for a single net location (scheme, host, and port), it will be cached for
4242
the duration of the command and used for other queries to that net location. Authentication is not
4343
cached across invocations of uv.
4444

45-
Note `--keyring-provider subprocess` or `UV_KEYRING_PROVIDER=subprocess` must be provided to enable
46-
keyring-based authentication.
45+
`.netc` authentication is enabled by default, and will respect the `NETRC` environment variable if
46+
defined, falling back to `~/.netrc` if not.
47+
48+
To enable keyring-based authentication, pass the `--keyring-provider subprocess` command-line
49+
argument to uv, or set `UV_KEYRING_PROVIDER=subprocess`.
4750

4851
Authentication may be used for hosts specified in the following contexts:
4952

docs/configuration/environment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ In addition, uv respects the following environment variables:
134134
- `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`: The proxy to use for all HTTP/HTTPS requests.
135135
- `HTTP_TIMEOUT` (or `UV_HTTP_TIMEOUT`): If set, uv will use this value (in seconds) as the timeout
136136
for HTTP reads (default: 30 s).
137+
- `NETRC`: If set, uv will read authentication information from this file instead of `~/.netrc`.
137138
- `PYC_INVALIDATION_MODE`: The validation modes to use when run with `--compile`. See:
138139
[`PycInvalidationMode`](https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode).
139140
- `VIRTUAL_ENV`: Used to detect an activated virtual environment.

0 commit comments

Comments
 (0)