{"record":{"id":"8d500eb15551109b","repo":"wavetermdev/waveterm","slug":"failed-to-resolve-gofmt-path-w","errorCode":null,"errorMessage":"failed to resolve gofmt path: %w","messagePattern":"failed to resolve gofmt path: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/waveappstore/waveappstore.go","lineNumber":430,"sourceCode":"\t}\n\n\tappDir, err := GetAppDir(appId)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfilePath, err := validateAndResolveFilePath(appDir, fileName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif filepath.Ext(filePath) != \".go\" {\n\t\treturn fmt.Errorf(\"file is not a Go file: %s\", fileName)\n\t}\n\n\tgofmtPath, err := waveapputil.ResolveGoFmtPath()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve gofmt path: %w\", err)\n\t}\n\n\tcmd := exec.Command(gofmtPath, \"-w\", filePath)\n\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"gofmt failed: %w\\nOutput: %s\", err, string(output))\n\t}\n\n\treturn nil\n}\n\nfunc ListAllAppFiles(appId string) (*fileutil.ReadDirResult, error) {\n\tif err := ValidateAppId(appId); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid appId: %w\", err)\n\t}\n\n\tappDir, err := GetAppDir(appId)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/waveappstore/waveappstore.go#L412-L448","documentation":"FormatGoFile locates the gofmt binary via waveapputil.ResolveGoFmtPath(). If gofmt cannot be found (not installed, not in PATH, or the app's resolved toolchain is missing), the failure is wrapped as \"failed to resolve gofmt path\". This is an environment/toolchain issue, not a problem with the file.","triggerScenarios":"ResolveGoFmtPath fails because the Go toolchain is not installed, gofmt is absent from PATH, or the environment's GOROOT is unset/incorrect.","commonSituations":"Running Wave on a machine without Go installed; a stripped-down/CI image missing the Go toolchain; GOROOT pointing at a removed SDK version after a Go upgrade.","solutions":["Install the Go toolchain (which ships gofmt) or add its bin directory to PATH","Verify with `which gofmt` / `go env GOROOT` that gofmt is resolvable in the environment running the app server","Set GOROOT/PATH correctly for the process if Go is installed in a non-standard location","If available, use an alternate formatting path or format the file outside Wave with a local gofmt"],"exampleFix":"// before (shell)\n./wave\n// after (shell)\nexport PATH=$PATH:/usr/local/go/bin\nexport GOROOT=/usr/local/go\n./wave","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"gofmt\"); err != nil {\n\treturn errors.New(\"gofmt not available in PATH; install the Go toolchain\")\n}","typeGuard":null,"tryCatchPattern":"if err := FormatGoFile(appId, fileName); err != nil {\n\tif strings.Contains(err.Error(), \"failed to resolve gofmt path\") {\n\t\treturn fmt.Errorf(\"formatting unavailable: Go toolchain missing (%v)\", err)\n\t}\n\treturn err\n}","preventionTips":["Install the Go toolchain on any machine running the app server","Ensure PATH includes the Go bin directory for the server process","Verify GOROOT resolves after Go version upgrades","Check `which gofmt` in health checks before exposing format features"],"tags":["environment","gofmt","toolchain"],"backgroundTag":"binary-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}