wavetermdev/waveterm · error
failed to resolve gofmt path: %w
Error message
failed to resolve gofmt path: %w
What it means
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.
Source
Thrown at pkg/waveappstore/waveappstore.go:430
}
appDir, err := GetAppDir(appId)
if err != nil {
return err
}
filePath, err := validateAndResolveFilePath(appDir, fileName)
if err != nil {
return err
}
if filepath.Ext(filePath) != ".go" {
return fmt.Errorf("file is not a Go file: %s", fileName)
}
gofmtPath, err := waveapputil.ResolveGoFmtPath()
if err != nil {
return fmt.Errorf("failed to resolve gofmt path: %w", err)
}
cmd := exec.Command(gofmtPath, "-w", filePath)
if output, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("gofmt failed: %w\nOutput: %s", err, string(output))
}
return nil
}
func ListAllAppFiles(appId string) (*fileutil.ReadDirResult, error) {
if err := ValidateAppId(appId); err != nil {
return nil, fmt.Errorf("invalid appId: %w", err)
}
appDir, err := GetAppDir(appId)
if err != nil {
return nil, errView on GitHub (pinned to a4447c1563)
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
Example fix
// before (shell) ./wave // after (shell) export PATH=$PATH:/usr/local/go/bin export GOROOT=/usr/local/go ./wave
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := exec.LookPath("gofmt"); err != nil {
return errors.New("gofmt not available in PATH; install the Go toolchain")
} Try / catch
if err := FormatGoFile(appId, fileName); err != nil {
if strings.Contains(err.Error(), "failed to resolve gofmt path") {
return fmt.Errorf("formatting unavailable: Go toolchain missing (%v)", err)
}
return err
} Prevention
- 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
When it happens
Trigger: ResolveGoFmtPath fails because the Go toolchain is not installed, gofmt is absent from PATH, or the environment's GOROOT is unset/incorrect.
Common situations: 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.
Related errors
- setting auth key: %v
- no WAVETERM_TABID env var set
- no WAVETERM_TABID env var set
- No appropriate secret manager found, cannot set secrets
- no WAVETERM_TABID env var set
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/8d500eb15551109b.
Report an issue: GitHub.