go-delve/delve · error
error running go list %v: output %q
Error message
error running go list %v: output %q
What it means
MakeGuessSusbtitutePathIn runs 'go list --json all' to build a module-to-directory mapping for substitute-path guessing; if the command fails, the error (including the captured output) is returned wrapped in this message. Typically means the Go toolchain is missing or the module graph is broken.
Source
Thrown at service/rpc2/client.go:639
type goListEntry struct {
Dir string
ImportPath string
Name string
Module *goListModule
}
type goListModule struct {
Path string
}
// MakeGuessSusbtitutePathIn returns a mapping from modules to client
// directories using "go list".
func MakeGuessSusbtitutePathIn() (*api.GuessSubstitutePathIn, error) {
cmd := exec.Command("go", "list", "--json", "all")
buf, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("error running go list %v: output %q", err, string(buf))
}
importPathOfMainPackage := ""
importPathOfMainPackageOk := true
mod2dir := make(map[string]string)
d := json.NewDecoder(bytes.NewReader(buf))
for d.More() {
var e goListEntry
err := d.Decode(&e)
if err != nil {
return nil, err
}
if e.Module == nil {
continue
}
if !strings.HasPrefix(e.ImportPath, e.Module.Path) {
continue
}
pkgWithoutModule := e.ImportPath[len(e.Module.Path):]View on GitHub (pinned to a23773e6c3)
Solutions
- Ensure 'go' is installed and on PATH: run 'go version' in the target's working directory
- Run 'go list --json all' manually in the program directory to see the real error
- Run 'go mod tidy' to fix inconsistent module requirements
- Check GOPROXY/GOFLAGS environment variables and network access
Example fix
// before
sub, err := client.MakeGuessSusbtitutePathIn() // fails: go not found
// after (ensure env)
cmd.Env = append(os.Environ(), "PATH="+goBinDir+":"+os.Getenv("PATH"))
sub, err := client.MakeGuessSusbtitutePathIn() Defensive patterns
Strategy: validation
Validate before calling
if _, err := exec.LookPath("go"); err != nil { return fmt.Errorf("go toolchain required") }
if _, err := os.Stat("go.mod"); err != nil { return fmt.Errorf("run in module directory") } Try / catch
sub, err := client.MakeGuessSusbtitutePathIn()
if err != nil && strings.Contains(err.Error(), "error running go list") {
// fall back to manually configured substitute paths
} Prevention
- Verify 'go version' works in the target's environment before using GuessSubstitutePathIn
- Run 'go mod tidy' after dependency changes
- Keep GOPROXY/network reachable in CI debug environments
- Configure substitutePath manually as a fallback
When it happens
Trigger: Calling the GuessSubstitutePathIn RPC (or the client helper) in an environment where exec.Command("go","list","--json","all") exits non-zero.
Common situations: go not installed or not on PATH in the debug session; go.mod/go.sum inconsistent (missing requirements); GOFLAGS/GOPROXY misconfigured; network blocked during module download.
Related errors
- could not determine path for module %s (got %q and %q)
- too many arguments to "config substitutePath"
- could not find rule for %q
- could not find rule for %q
- Process %d has exited with status %d
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/8b1e963722dd4c34.
Report an issue: GitHub.