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

  1. Set `name` to one of the supported values exactly: bash, zsh, fish, pwsh, nu, elvish, xonsh, yash (lowercase, no extra spaces)
  2. If the desired shell has no rc-file support (e.g. cmd), configure it manually instead of via the DSC shell resource
  3. Trim whitespace and normalize case in the DSC document
  4. 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

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


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/270d9df9fcdf83dc. Report an issue: GitHub.