wavetermdev/waveterm · error

failed to get version for %s: %w

Error message

failed to get version for %s: %w

What it means

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.

Source

Thrown at pkg/util/shellutil/shellutil.go:539

	case ShellType_bash:
		cmd = exec.CommandContext(ctx, shellPath, "--version")
		versionRegex = bashVersionRegexp
	case ShellType_zsh:
		cmd = exec.CommandContext(ctx, shellPath, "--version")
		versionRegex = zshVersionRegexp
	case ShellType_fish:
		cmd = exec.CommandContext(ctx, shellPath, "--version")
		versionRegex = fishVersionRegexp
	case ShellType_pwsh:
		cmd = exec.CommandContext(ctx, shellPath, "--version")
		versionRegex = pwshVersionRegexp
	default:
		return "", fmt.Errorf("unsupported shell type: %s", shellType)
	}

	output, err := cmd.CombinedOutput()
	if err != nil {
		return "", fmt.Errorf("failed to get version for %s: %w", shellType, err)
	}

	outputStr := strings.TrimSpace(string(output))
	matches := versionRegex.FindStringSubmatch(outputStr)
	if len(matches) < 2 {
		return "", fmt.Errorf("failed to parse version from output: %q", outputStr)
	}

	return matches[1], nil
}

func FixupWaveZshHistory() error {
	if runtime.GOOS != "darwin" {
		return nil
	}

	hasHistory, size := HasWaveZshHistory()
	if !hasHistory {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Confirm the shell path exists and is executable (ls -l $(SHELL); reinstall the shell if missing).
  2. Run `<shell> --version` manually to see the actual failure and fix the shell installation.
  3. Increase the version-probe context timeout if slow environments cause timeouts.
  4. Check that the process can spawn binaries from that path (mount noexec, sandbox/AV interference).

Example fix

// before: SHELL points at removed binary
$ ls -l /usr/bin/fish  # No such file
// after
$ sudo apt install fish  # or chsh -s /bin/bash; then re-detect
Defensive patterns

Strategy: retry

Validate before calling

// verify the shell binary exists and supports --version before probing
if _, err := os.Stat(shellPath); err != nil {
	return fmt.Errorf("shell binary missing: %w", err)
}
if fi, err := os.Stat(shellPath); err == nil && fi.Mode().Perm()&0111 == 0 {
	return fmt.Errorf("shell binary not executable: %s", shellPath)
}

Try / catch

shellType, version, err := shellutil.DetectShellTypeAndVersionFromPath(shellPath)
if err != nil {
	if strings.Contains(err.Error(), "failed to get version") {
		// non-fatal: proceed with empty version
		return shellType, "", nil
	}
	return shellType, "", err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/2077bb9cbd31c2ea. Report an issue: GitHub.