{"id":"e507b7bf259eda65","repo":"gohugoio/hugo","slug":"failed-to-get-q-w","errorCode":null,"errorMessage":"failed to get %q: %w","messagePattern":"failed to get %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":358,"sourceCode":"\t\t\t} else if update && patch {\n\t\t\t\targs = append(args, \"-u=patch\")\n\t\t\t}\n\t\t\targs = append(args, m)\n\n\t\t\tif err := c.get(args...); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n\n\treturn c.get(args...)\n}\n\nfunc (c *Client) get(args ...string) error {\n\tif err := c.runGo(context.Background(), c.logger.StdOut(), append([]string{\"get\"}, args...)...); err != nil {\n\t\treturn fmt.Errorf(\"failed to get %q: %w\", args, err)\n\t}\n\treturn nil\n}\n\n// Init initializes this as a Go Module with the given path.\n// If path is empty, Go will try to guess.\n// If this succeeds, this project will be marked as Go Module.\nfunc (c *Client) Init(path string) error {\n\terr := c.runGo(context.Background(), c.logger.StdOut(), \"mod\", \"init\", path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to init modules: %w\", err)\n\t}\n\n\tc.GoModulesFilename = filepath.Join(c.ccfg.WorkingDir, goModFilename)\n\n\treturn nil\n}\n","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/client.go#L340-L376","documentation":"Returned by Hugo's module Client.get when `go get <args>` fails. Hugo shells out to the Go toolchain to add or update module dependencies (e.g. via `hugo mod get`), and this wraps any non-zero exit from that command with the arguments that were passed.","triggerScenarios":"Running `hugo mod get [-u] <module>` or Client.Get when `go get` exits non-zero: unresolvable module path, no matching version, network/proxy failure, missing go.mod in the project, or a Go binary too old for the module's go directive.","commonSituations":"Typos in module paths in `hugo mod get`, private repos without GOPRIVATE/credentials configured, corporate proxies blocking proxy.golang.org, running outside a directory initialized with `hugo mod init`, or an outdated Go installation.","solutions":["Verify the module path and version exist (`go list -m -versions <path>`).","Run `hugo mod init <path>` first if the project has no go.mod.","For private repos, set GOPRIVATE and configure git credentials.","Check network/proxy access to proxy.golang.org or set GOPROXY.","Upgrade the Go toolchain if the error mentions an unsupported go version."],"exampleFix":"# before\nhugo mod get github.com/user/theme-typo\n# after\nhugo mod init github.com/me/mysite\nhugo mod get github.com/user/theme@v1.2.0","handlingStrategy":"validation","validationCode":"// verify module path is well-formed before calling Get\nif err := module.CheckPath(modPath); err != nil {\n    return fmt.Errorf(\"invalid module path %q: %w\", modPath, err)\n}","typeGuard":null,"tryCatchPattern":"if err := client.Get(modPath); err != nil {\n    var execErr *exec.ExitError\n    if errors.As(err, &execErr) {\n        // go mod get failed — inspect stderr, likely bad path/version or network\n    }\n    return err\n}","preventionTips":["Validate module paths with golang.org/x/mod/module.CheckPath before invoking Get","Ensure the go binary is on PATH and GOPROXY/GONOSUMCHECK env is configured before client construction","Pin explicit versions (path@vX.Y.Z) instead of @latest to avoid resolution surprises","Check network/proxy reachability (GOPROXY endpoint) in a preflight step for CI environments"],"tags":["go-modules","hugo-mod","network","toolchain"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}