JanDeDobbeleer/oh-my-posh · error
unsupported shell type: %s
Error message
unsupported shell type: %s
What it means
getShellConfigPath falls through to its default branch when the Shell resource's Name does not match any supported shell constant, returning this error. It protects against writing an init line into the wrong file for an unknown shell. The unsupported value is included in the message.
Source
Thrown at src/cli/dsc/shell.go:121
return filepath.Join(home, ".bash_profile"), nil
case shell.ZSH:
return filepath.Join(home, ".zshrc"), nil
case shell.FISH:
configDir := filepath.Join(home, ".config", "fish")
return filepath.Join(configDir, "config.fish"), nil
case shell.PWSH:
return cmd.Run(s.Name, "-NoProfile", "-Command", "$PROFILE")
case shell.NU:
return cmd.Run("nu", "-c", "$nu.config-path")
case shell.ELVISH:
return filepath.Join(home, ".elvish", "rc.elv"), nil
case shell.XONSH:
return filepath.Join(home, ".xonshrc"), nil
case shell.YASH:
return filepath.Join(home, ".yashrc"), nil
default:
return "", fmt.Errorf("unsupported shell type: %s", s.Name)
}
}
func (s *Shell) validateShellConfigPath(configPath string) error {
log.Debug("validating shell config path:", configPath)
_, err := os.Stat(configPath)
if err != nil && !os.IsNotExist(err) {
return err
}
if !os.IsNotExist(err) {
return nil
}
log.Debug("shell config file does not exist")
if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil {View on GitHub (pinned to 0976794618)
Solutions
- Set `name` to one of the supported values exactly: bash, zsh, fish, pwsh, nu, elvish, xonsh, yash (lowercase, no extra spaces)
- If the desired shell has no rc-file support (e.g. cmd), configure it manually instead of via the DSC shell resource
- Trim whitespace and normalize case in the DSC document
- Check the release notes if a shell name changed between oh-my-posh versions
Example fix
// before
{ "name": "PowerShell", "command": "oh-my-posh init pwsh" }
// after
{ "name": "pwsh", "command": "oh-my-posh init pwsh" } Defensive patterns
Strategy: validation
Validate before calling
var supported = map[string]bool{
"bash": true, "zsh": true, "fish": true, "pwsh": true,
"nu": true, "elvish": true, "xonsh": true, "yash": true,
}
name := strings.ToLower(strings.TrimSpace(shellName))
if !supported[name] {
return fmt.Errorf("shell %q is not supported; use one of bash, zsh, fish, pwsh, nu, elvish, xonsh, yash", shellName)
} Try / catch
if err := sh.Apply(); err != nil {
if strings.Contains(err.Error(), "unsupported shell type") {
return fmt.Errorf("correct the `name` field in the DSC document: %w", err)
}
return err
} Prevention
- Use exact lowercase shell names from oh-my-posh's supported list
- Normalize/trim user-supplied shell names before writing them into DSC documents
- For shells without rc-file support (e.g. cmd), configure manually instead of using the DSC shell resource
- Validate DSC documents against shell.schema.json before applying
When it happens
Trigger: Applying a DSC Shell resource whose `name` field is empty, typoed ("ZSH " with whitespace, "powerShell", "cmd"), or names a shell oh-my-posh does not configure rc files for (e.g. cmd, tcsh).
Common situations: Hand-edited DSC documents; uppercase or differently spelled shell names; shells like cmd that have no rc file support; an old DSC document using a shell name that changed between versions.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- source file %s does not match format %s
- failed to get shell config path: %w
- failed to get home directory
- --data-only and --data-derive contradict each other: one for
- font path must be a valid URL
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/270d9df9fcdf83dc.
Report an issue: GitHub.