{"record":{"id":"2077bb9cbd31c2ea","repo":"wavetermdev/waveterm","slug":"failed-to-get-version-for-s-w","errorCode":null,"errorMessage":"failed to get version for %s: %w","messagePattern":"failed to get version for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/shellutil/shellutil.go","lineNumber":539,"sourceCode":"\tcase ShellType_bash:\n\t\tcmd = exec.CommandContext(ctx, shellPath, \"--version\")\n\t\tversionRegex = bashVersionRegexp\n\tcase ShellType_zsh:\n\t\tcmd = exec.CommandContext(ctx, shellPath, \"--version\")\n\t\tversionRegex = zshVersionRegexp\n\tcase ShellType_fish:\n\t\tcmd = exec.CommandContext(ctx, shellPath, \"--version\")\n\t\tversionRegex = fishVersionRegexp\n\tcase ShellType_pwsh:\n\t\tcmd = exec.CommandContext(ctx, shellPath, \"--version\")\n\t\tversionRegex = pwshVersionRegexp\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported shell type: %s\", shellType)\n\t}\n\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get version for %s: %w\", shellType, err)\n\t}\n\n\toutputStr := strings.TrimSpace(string(output))\n\tmatches := versionRegex.FindStringSubmatch(outputStr)\n\tif len(matches) < 2 {\n\t\treturn \"\", fmt.Errorf(\"failed to parse version from output: %q\", outputStr)\n\t}\n\n\treturn matches[1], nil\n}\n\nfunc FixupWaveZshHistory() error {\n\tif runtime.GOOS != \"darwin\" {\n\t\treturn nil\n\t}\n\n\thasHistory, size := HasWaveZshHistory()\n\tif !hasHistory {","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/util/shellutil/shellutil.go#L521-L557","documentation":"After running `<shell> --version`, getShellVersion wraps a non-zero exit or exec failure (binary not found, not executable, timeout via CommandContext) with this error using %w. The shell was recognized but its version probe failed, so Wave cannot record the shell version.","triggerScenarios":"DetectShellTypeAndVersionFromPath → getShellVersion where exec.CommandContext(shellPath, \"--version\") fails: the binary path doesn't exist or isn't executable, the shell crashes on --version, the context deadline expires, or PATH resolution fails.","commonSituations":"Broken symlinks in /bin after partial upgrades (e.g. fish removed but SHELL still points to it); shells that don't support --version in odd build variants; very slow disk/spawn causing context timeout; sandboxed environments blocking process spawn.","solutions":["Confirm the shell path exists and is executable (ls -l $(SHELL); reinstall the shell if missing).","Run `<shell> --version` manually to see the actual failure and fix the shell installation.","Increase the version-probe context timeout if slow environments cause timeouts.","Check that the process can spawn binaries from that path (mount noexec, sandbox/AV interference)."],"exampleFix":"// before: SHELL points at removed binary\n$ ls -l /usr/bin/fish  # No such file\n// after\n$ sudo apt install fish  # or chsh -s /bin/bash; then re-detect","handlingStrategy":"retry","validationCode":"// verify the shell binary exists and supports --version before probing\nif _, err := os.Stat(shellPath); err != nil {\n\treturn fmt.Errorf(\"shell binary missing: %w\", err)\n}\nif fi, err := os.Stat(shellPath); err == nil && fi.Mode().Perm()&0111 == 0 {\n\treturn fmt.Errorf(\"shell binary not executable: %s\", shellPath)\n}","typeGuard":null,"tryCatchPattern":"shellType, version, err := shellutil.DetectShellTypeAndVersionFromPath(shellPath)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to get version\") {\n\t\t// non-fatal: proceed with empty version\n\t\treturn shellType, \"\", nil\n\t}\n\treturn shellType, \"\", err\n}","preventionTips":["Keep $SHELL pointing at an installed, executable binary — fix broken symlinks after package upgrades.","Run `<shell> --version` manually to verify the shell supports the flag in your build.","Allow a generous timeout on the exec context for slow/loaded machines.","Treat version-detection failure as non-fatal and degrade gracefully (empty version) in callers."],"tags":["shell-detection","version-probe","process-execution"],"backgroundTag":"shell-version-probe-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}