]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: do not call base.fatal for an unset HOME for GOAUTH=netrc
authorSam Thanawalla <samthanawalla@google.com>
Thu, 23 Jan 2025 19:35:34 +0000 (19:35 +0000)
committerSam Thanawalla <samthanawalla@google.com>
Mon, 27 Jan 2025 18:46:57 +0000 (10:46 -0800)
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>

src/cmd/go/internal/auth/auth.go
src/cmd/go/testdata/script/goauth_netrc.txt

index bd80222427ae36fec075c91ffceefcc6355d5c99..79e0d8b5e8f2f62e1e2c803e103cc43f69bea4a0 100644 (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
index 26e03f8968c5b301f8249d62900053ecaf318553..0baa09de1ecaf9cf559531111b9677996b2d8328 100644 (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 --