apache/answer · error
failed to run go list: %w
Error message
failed to run go list: %w
What it means
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>'.
Source
Thrown at internal/cli/build.go:327
pluginName := filepath.Base(p.Name)
if !strings.HasPrefix(p.Name, "github.com/apache/answer-plugins/") {
fmt.Printf("try to copy dir from %s to %s\n", pluginDir, filepath.Join(pluginsDir, pluginName))
err = copyDirEntries(os.DirFS(pluginDir), ".", filepath.Join(pluginsDir, pluginName), "node_modules")
if err != nil {
return err
}
}
}
return nil
}
// copyUIFiles copy ui files from answer module to tmp dir
func copyUIFiles(b *buildingMaterial) (err error) {
goListCmd := b.newExecCmd("go", "list", "-mod=mod", "-m", "-f", "{{.Dir}}", "github.com/apache/answer")
buf := new(bytes.Buffer)
goListCmd.Stdout = buf
if err = goListCmd.Run(); err != nil {
return fmt.Errorf("failed to run go list: %w", err)
}
answerDir := strings.TrimSpace(buf.String())
goModUIDir := filepath.Join(answerDir, "ui")
localUIBuildDir := filepath.Join(b.tmpDir, "vendor/github.com/apache/answer/ui/")
// The node_modules folder generated during development will interfere packaging, so it needs to be ignored.
if err = copyDirEntries(os.DirFS(goModUIDir), ".", localUIBuildDir, "node_modules"); err != nil {
return fmt.Errorf("failed to copy ui files: %w", err)
}
pluginsDir := filepath.Join(b.tmpDir, "vendor/github.com/apache/answer-plugins/")
localUIPluginDir := filepath.Join(localUIBuildDir, "src/plugins/")
// copy plugins dir
fmt.Printf("try to copy dir from %s to %s\n", pluginsDir, localUIPluginDir)
// if plugins dir not exist means no plugins
if !dir.CheckDirExist(pluginsDir) {View on GitHub (pinned to 3b9f137061)
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.
Example fix
// before $ cd ./some-random-dir && answer build // after $ cd /path/to/project-with-answer-in-go.mod $ go mod download github.com/apache/answer $ answer build
Defensive patterns
Strategy: try-catch
Validate before calling
go version || { echo 'go toolchain required'; exit 1; }
go list -mod=mod -m -f '{{.Dir}}' github.com/apache/answer || { echo 'answer module not in go.mod; set ANSWER_MODULE'; exit 1; } Try / catch
if err := copyUIFiles(b); err != nil {
if strings.HasPrefix(err.Error(), "failed to run go list:") {
if dir := os.Getenv("ANSWER_MODULE"); dir != "" {
return copyUIFromLocal(dir)
}
}
return err
} Prevention
- 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
When it happens
Trigger: `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).
Common situations: 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).
Related errors
- failed to clone %s@%s: %w Tip: set ANSWER_MODULE to a local
- failed to install plugin dependencies: %w
- failed to open source file %s: %w
- failed to create destination file %s: %w
- validate check exception
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/24d72c0b1e638e4f.
Report an issue: GitHub.