cmd/go: do not call base.fatal for an unset HOME for GOAUTH=netrc

This CL silences errors caused by GOAUTH=netrc and HOME being unset.
Instead, we log the error if the -x flag is set.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ibd323769f3562c169ebf559e060e9afbb63047bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/643917
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Sam Thanawalla 2025-01-23 19:35:34 +00:00
parent 475e08349d
commit f70aa3824b
2 changed files with 15 additions and 1 deletions

View file

@ -70,7 +70,8 @@ func runGoAuth(client *http.Client, res *http.Response, url string) {
case "netrc":
lines, err := readNetrc()
if err != nil {
base.Fatalf("go: could not parse netrc (GOAUTH=%s): %v", cfg.GOAUTH, err)
cmdErrs = append(cmdErrs, fmt.Errorf("GOAUTH=%s: %v", command, err))
continue
}
// Process lines in reverse so that if the same machine is listed
// multiple times, we end up saving the earlier one

View file

@ -53,6 +53,19 @@ go get vcs-test.golang.org/auth/or401
env NETRC=$WORK/missing
! go get vcs-test.golang.org/auth/or401
stderr '^\tserver response: ACCESS DENIED, buddy$'
[short] skip 'requires a remote vcs lookup'
[!git] skip
# An unset home directory should warn the user but not cause a failure.
env NETRC=
env HOME=
env USERPROFILE=
env home=
go get -x vcs-test.golang.org/git/emptytest.git
[!GOOS:windows] [!GOOS:plan9] stderr 'GOAUTH=netrc: \$HOME is not defined'
[GOOS:windows] stderr 'GOAUTH=netrc: \%userprofile\% is not defined'
[GOOS:plan9] stderr 'GOAUTH=netrc: \$home is not defined'
-- go.mod --
module private.example.com
-- $WORK/empty --