golang/go · warning

GOAUTH=%s: %v

Error message

GOAUTH=%s: %v

What it means

Emitted from the `netrc` branch of runGoAuth when readNetrc() returns an error. The error is non-fatal: it is appended to cmdErrs and only logged (under `go -x`) if no GOAUTH command ultimately supplies a credential for the URL. The %s is the command token (netrc) and %v is the underlying readNetrc error (permission denied, parse error, missing HOME).

Source

Thrown at src/cmd/go/internal/auth/auth.go:74

	// The GOAUTH commands are processed in reverse order to prioritize
	// credentials in the order they were specified.
	slices.Reverse(goAuthCmds)
	for _, command := range goAuthCmds {
		command = strings.TrimSpace(command)
		words := strings.Fields(command)
		if len(words) == 0 {
			base.Fatalf("go: GOAUTH encountered an empty command (GOAUTH=%s)", cfg.GOAUTH)
		}
		switch words[0] {
		case "off":
			if len(goAuthCmds) != 1 {
				base.Fatalf("go: GOAUTH=off cannot be combined with other authentication commands (GOAUTH=%s)", cfg.GOAUTH)
			}
			return
		case "netrc":
			lines, err := readNetrc()
			if err != nil {
				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
			// (overwriting later ones). This matches the way the go command
			// worked before GOAUTH.
			for i := len(lines) - 1; i >= 0; i-- {
				l := lines[i]
				r := http.Request{Header: make(http.Header)}
				r.SetBasicAuth(l.login, l.password)
				storeCredential(l.machine, r.Header)
			}
		case "git":
			if len(words) != 2 {
				base.Fatalf("go: GOAUTH=git dir method requires an absolute path to the git working directory")
			}
			dir := words[1]
			if !filepath.IsAbs(dir) {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Verify ~/.netrc exists and is owner-readable: `chmod 600 ~/.netrc`.
  2. Validate netrc syntax: each `machine <host>` (or `default`) entry followed by `login <u>` and `password <p>`.
  3. Ensure HOME is set (`echo $HOME`) so the netrc path resolves.
  4. Run `go get -x <url>` to surface the deferred error message.
  5. If netrc is unnecessary, remove `netrc` from the GOAUTH list.
Defensive patterns

Strategy: validation

Validate before calling

// Validate netrc readability and basic syntax before relying on GOAUTH=netrc.
home, err := os.UserHomeDir()
if err != nil { return err }
p := filepath.Join(home, ".netrc")
info, err := os.Stat(p)
if err == nil && info.Mode().Perm()&0077 != 0 {
    return fmt.Errorf("%s permissions too open; chmod 600", p)
}

Prevention

When it happens

Trigger: GOAUTH contains `netrc` and readNetrc() fails: ~/.netrc (or _netrc on Windows) is unreadable due to permissions, missing, or syntactically malformed, or HOME is unset so the path cannot be resolved.

Common situations: ~/.netrc with overly permissive or restrictive permissions (many tools require 0600); a netrc with a token sequence netrc cannot parse; HOME unset in a container/CI; netrc pointing at a private repo that requires a credential netrc can't supply.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/c72bcdacb32736a2. Report an issue: GitHub.