{"id":"8e1902be9f79315e","repo":"gohugoio/hugo","slug":"go-command-failed-s","errorCode":null,"errorMessage":"go command failed: %s","messagePattern":"go command failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":820,"sourceCode":"The easiest is to just enter a valid branch name there, e.g. master, which would be what you put in place of 'v0.5.1' in the example below.\n\nrequire github.com/gohugoio/hugo-mod-jslibs/instantpage v0.5.1\n\nIf you then run 'hugo mod graph' it should resolve itself to the most recent version (or commit if no semver versions are available).`)\n\t\t}\n\n\t\t_, ok := err.(*exec.ExitError)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"failed to execute 'go %v': %s %T\", args, err, err)\n\t\t}\n\n\t\t// Too old Go version\n\t\tif strings.Contains(stderr.String(), \"flag provided but not defined\") {\n\t\t\tc.goBinaryStatus = goBinaryStatusTooOld\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"go command failed: %s\", stderr)\n\n\t}\n\n\treturn nil\n}\n\nvar goOutputReplacer = strings.NewReplacer(\n\t\"go: to add module requirements and sums:\", \"hugo: to add module requirements and sums:\",\n\t\"go mod tidy\", \"hugo mod tidy\",\n)\n\ntype goOutputReplacerWriter struct {\n\tw io.Writer\n}\n\nfunc (w goOutputReplacerWriter) Write(p []byte) (n int, err error) {\n\ts := goOutputReplacer.Replace(string(p))\n\t_, err = w.w.Write([]byte(s))","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/client.go#L802-L838","documentation":"Emitted in `runGo` (modules/client.go:820) when the `go` command started successfully but exited non-zero (`*exec.ExitError`), and the failure wasn't one of the specially handled cases (go binary too old, unknown revision). Hugo surfaces go's captured stderr verbatim so the underlying toolchain problem (network, auth, go.mod issues) is visible to the user.","triggerScenarios":"`hugo mod get/tidy/vendor/graph/verify` or module collection during build, where `go` itself fails: unresolvable module path, network failure reaching proxy.golang.org, private repo auth failure, malformed go.mod, checksum mismatch against go.sum, or an invalid version query.","commonSituations":"Typo'd module path in `module.imports` in hugo config; private GitHub theme modules without GONOPRIVATE/credentials configured; offline or firewalled CI without GOPROXY access; stale go.sum after a module's tag was moved; GOFLAGS/GOPROXY misconfiguration.","solutions":["Read the embedded stderr text — it is go's own error and usually names the exact module and cause.","Verify the module path in your Hugo config exists and is reachable: `go list -m <path>@latest`.","For private modules set `GOPRIVATE=github.com/yourorg/*` and configure git credentials.","If checksum errors, run `hugo mod clean` then `hugo mod tidy` to refresh go.mod/go.sum.","Check GOPROXY/network access from the build environment."],"exampleFix":"# before (hugo.toml)\n[[module.imports]]\npath = \"github.com/user/my-privat-theme\"  # typo, private, no auth\n# after\n# fix path and allow private access\n[[module.imports]]\npath = \"github.com/user/my-private-theme\"\n# env: GOPRIVATE=github.com/user/*","handlingStrategy":"try-catch","validationCode":"// Pre-flight: run `go mod verify` / check network + GOPROXY before builds\n// e.g. exec.Command(\"go\", \"env\", \"GOPROXY\").Run()","typeGuard":null,"tryCatchPattern":"if err := client.Get(mod); err != nil {\n    var cerr *modules.ClientError // wraps stderr output\n    if errors.As(err, &cerr) {\n        log.Printf(\"go command stderr: %s\", cerr.Err)\n    }\n    return err\n}","preventionTips":["Surface the wrapped stderr text — it contains the real cause (auth, proxy, bad version)","Configure GOPROXY/GONOSUMCHECK/GOPRIVATE correctly for private module hosts","Run `hugo mod verify` in CI to catch sum mismatches early","Retry only for transient network failures, not for resolution errors"],"tags":["hugo-modules","go-toolchain","network","configuration"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}