Missing default .netrc location
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
Search directory from environment variable _USERPROFILE_ is missing in the .netrc discovery implementation in [GoogleAuthUtils.java](https://github.com/bazelbuild/bazel/blob/8.2.1/src/main/java/com/google/devtools/build/lib/authandtls/GoogleAuthUtils.java#L355)
Issue https://github.com/bazelbuild/bazel/issues/10867 already requested adding the windows default _USERPROFILE_ location - but it is only realized in [UrlRewriter.java](https://github.com/bazelbuild/bazel/blob/8.2.1/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/UrlRewriter.java#L302)
E.g.
_http_archive_ successfully uses the .netrc in _USERPROFILE_ but bazel option _--remote_cache_ does not as it uses the faulty/incomplete implementation.
### Which category does this issue belong to?
Remote Execution
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Windows host with Bazel Version 8.2.1 and a .netrc file with valid credentials for the remote cache in the windows user home directory.
Environment Variables _NETRC_ and _HOME_ are not set or at least do not contain a .netrc file.
Execute a Bazel build using a remote cache
_bazel build --remote_cache=SERVER TARGET -s_.
You should get a HTTP error code 401 "Unauthorized" and on inspection of the HTTP GET request you should see that the authentication header is missing.
### Which operating system are you running Bazel on?
Windows 10 Enterprise
### What is the output of `bazel info release`?
release 8.2.1
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
```text
```
### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
_No response_
### Have you found anything relevant by searching the web?
Feature request for _USERPROFILE_ usage for windows: https://github.com/bazelbuild/bazel/issues/10867
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start in src/main/java/com/google/devtools/build/lib/authandtls/GoogleAuthUtils.java at the .netrc discovery implementation, then compare the related logic in src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/UrlRewriter.java. Reproduce the Windows remote-cache case described with USERPROFILE set and HOME and NETRC unset. Done means remote-cache requests use credentials from the Windows user home .netrc.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication, build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100