{"record":{"id":"eba90a67ef3c9bc1","repo":"gohugoio/hugo","slug":"failed-to-execute-go-v-s-t","errorCode":null,"errorMessage":"failed to execute 'go %v': %s %T","messagePattern":"failed to execute 'go (.+?)': (.+?) %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":811,"sourceCode":"\t\t\tc.goBinaryStatus = goBinaryStatusNotFound\n\t\t\treturn nil\n\t\t}\n\n\t\tif strings.Contains(stderr.String(), \"invalid version: unknown revision\") {\n\t\t\t// See https://github.com/gohugoio/hugo/issues/6825\n\t\t\tc.logger.Println(`An unknown revision most likely means that someone has deleted the remote ref (e.g. with a force push to GitHub).\nTo resolve this, you need to manually edit your go.mod file and replace the version for the module in question with a valid ref.\n\nThe 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\",","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/client.go#L793-L829","documentation":"In runGo, cmd.Run() returned an error that is neither *exec.Error (binary not found — handled separately) nor *exec.ExitError (normal non-zero exit — handled separately). That leaves failures in starting/running the process itself: the %T prints the concrete error type to aid diagnosis. Essentially 'something prevented the go process from running at all, and it wasn't a missing binary or a clean exit code.'","triggerScenarios":"exec.Cmd.Run fails before producing an ExitError — permission denied on the go binary, fork/limits exhaustion (EMFILE, EAGAIN), context cancellation surfacing as a non-Exit error, or an OS-level refusal to spawn the process.","commonSituations":"Container with low ulimits (nproc/nofile), read-only filesystem blocking the binary, SELinux/AppArmor denying exec, or Hugo invoked with a cancelled context (timeout).","solutions":["Look at the %T and the wrapped error text: 'permission denied' → chmod/chown the go binary; 'resource temporarily unavailable' → raise ulimits.","Run the failing `go <args>` manually as the same user to reproduce.","In containers, raise `--ulimit nproc` and `--ulimit nofile` and confirm the go binary is executable and on PATH.","If context-cancellation, widen the timeout or avoid cancelling the build mid-flight."],"exampleFix":"// before: container ulimits too low -> spawn fails\n// after: raise limits\ndocker run --ulimit nofile=65536:65536 --ulimit nproc=4096:4096 ... hugo","handlingStrategy":"validation","validationCode":"// Validate the environment can spawn go before Hugo runs\nfunc ensureGoRunnable() error {\n  bin, err := exec.LookPath(\"go\")\n  if err != nil { return fmt.Errorf(\"go not on PATH: %w\", err) }\n  info, err := os.Stat(bin)\n  if err != nil { return err }\n  if info.Mode()&0o111 == 0 { return fmt.Errorf(\"go binary not executable: %s\", bin) }\n  // optional: probe spawn\n  return exec.Command(bin, \"env\").Run()\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["In containers set adequate --ulimit nproc and nofile.","Ensure the go binary is executable and on a writable/executable FS.","Avoid cancelling the build context while module ops run.","Watch for SELinux/AppKernel denials in audit logs."],"tags":["go-toolchain","exec","environment","hugo-module"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}