{"record":{"id":"24d72c0b1e638e4f","repo":"apache/answer","slug":"failed-to-run-go-list-w","errorCode":null,"errorMessage":"failed to run go list: %w","messagePattern":"failed to run go list: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/build.go","lineNumber":327,"sourceCode":"\t\tpluginName := filepath.Base(p.Name)\n\t\tif !strings.HasPrefix(p.Name, \"github.com/apache/answer-plugins/\") {\n\t\t\tfmt.Printf(\"try to copy dir from %s to %s\\n\", pluginDir, filepath.Join(pluginsDir, pluginName))\n\t\t\terr = copyDirEntries(os.DirFS(pluginDir), \".\", filepath.Join(pluginsDir, pluginName), \"node_modules\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// copyUIFiles copy ui files from answer module to tmp dir\nfunc copyUIFiles(b *buildingMaterial) (err error) {\n\tgoListCmd := b.newExecCmd(\"go\", \"list\", \"-mod=mod\", \"-m\", \"-f\", \"{{.Dir}}\", \"github.com/apache/answer\")\n\tbuf := new(bytes.Buffer)\n\tgoListCmd.Stdout = buf\n\tif err = goListCmd.Run(); err != nil {\n\t\treturn fmt.Errorf(\"failed to run go list: %w\", err)\n\t}\n\n\tanswerDir := strings.TrimSpace(buf.String())\n\tgoModUIDir := filepath.Join(answerDir, \"ui\")\n\tlocalUIBuildDir := filepath.Join(b.tmpDir, \"vendor/github.com/apache/answer/ui/\")\n\t// The node_modules folder generated during development will interfere packaging, so it needs to be ignored.\n\tif err = copyDirEntries(os.DirFS(goModUIDir), \".\", localUIBuildDir, \"node_modules\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to copy ui files: %w\", err)\n\t}\n\n\tpluginsDir := filepath.Join(b.tmpDir, \"vendor/github.com/apache/answer-plugins/\")\n\tlocalUIPluginDir := filepath.Join(localUIBuildDir, \"src/plugins/\")\n\n\t// copy plugins dir\n\tfmt.Printf(\"try to copy dir from %s to %s\\n\", pluginsDir, localUIPluginDir)\n\n\t// if plugins dir not exist means no plugins\n\tif !dir.CheckDirExist(pluginsDir) {","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/cli/build.go#L309-L345","documentation":"copyUIFiles runs `go list -mod=mod -m -f {{.Dir}} github.com/apache/answer` to locate the module directory containing the prebuilt UI files; if that command fails it returns 'failed to run go list: <err>'.","triggerScenarios":"`answer build` executed outside a Go module that depends on github.com/apache/answer, go missing from PATH, corrupted module cache, go.mod/go.sum out of sync, or the module not yet downloaded and download failing (offline).","commonSituations":"Running the build CLI in a directory without go.mod, CI images without the Go toolchain, vendoring inconsistencies (GOFLAGS=-mod=vendor conflicts), Go proxy unreachable (GOPROXY blocked).","solutions":["Run the build from a directory whose go.mod requires github.com/apache/answer (or set ANSWER_MODULE to a local checkout).","Ensure `go` is installed and on PATH in the build environment.","Run `go mod download github.com/apache/answer` (with correct GOPROXY) then retry the build.","Check go.mod/go.sum consistency (`go mod tidy`) and avoid -mod=vendor conflicts with -mod=mod usage."],"exampleFix":"// before\n$ cd ./some-random-dir && answer build\n// after\n$ cd /path/to/project-with-answer-in-go.mod\n$ go mod download github.com/apache/answer\n$ answer build","handlingStrategy":"try-catch","validationCode":"go version || { echo 'go toolchain required'; exit 1; }\ngo list -mod=mod -m -f '{{.Dir}}' github.com/apache/answer || { echo 'answer module not in go.mod; set ANSWER_MODULE'; exit 1; }","typeGuard":null,"tryCatchPattern":"if err := copyUIFiles(b); err != nil {\n  if strings.HasPrefix(err.Error(), \"failed to run go list:\") {\n    if dir := os.Getenv(\"ANSWER_MODULE\"); dir != \"\" {\n      return copyUIFromLocal(dir)\n    }\n  }\n  return err\n}","preventionTips":["Run builds in a directory with github.com/apache/answer in go.mod","Install the Go toolchain in build images","Run go mod download before building","Keep GOPROXY reachable or pre-warm the module cache","Use ANSWER_MODULE for hermetic/offline builds"],"tags":["build","go","toolchain","dependencies"],"backgroundTag":"go-list-failed","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}