JanDeDobbeleer/oh-my-posh · error
failed to get shell config path: %w
Error message
failed to get shell config path: %w
What it means
The dsc Shell resource's Apply resolves the shell's rc/config file path via getShellConfigPath and wraps any failure from that lookup with this message. It is a wrapper error: the cause is either a missing home directory, a failure of the external command used to query pwsh/nu profile paths, or an unsupported shell name.
Source
Thrown at src/cli/dsc/shell.go:68
return s.Name == other.Name
}
func (s *Shell) Resolve() (*Shell, bool) {
return nil, false
}
func (s *Shell) Apply() error {
if s.Command == "" {
return nil
}
log.Debug("applying shell configuration with command: %s", s.Command)
// Get the shell configuration file path
configPath, err := s.getShellConfigPath()
if err != nil {
return fmt.Errorf("failed to get shell config path: %w", err)
}
if err := s.validateShellConfigPath(configPath); err != nil {
return err
}
// Read current configuration
content, err := os.ReadFile(configPath)
if err != nil {
log.Debug("failed to read shell config file")
return err
}
contentStr, updated := s.updateShellConfig(string(content))
if !updated {
log.Debug("shell config already up to date, skipping write")
return nil
}View on GitHub (pinned to 0976794618)
Solutions
- Inspect the wrapped %w error to identify which lookup failed
- Ensure HOME (or the platform equivalent) is set to a valid, existing directory
- If name is pwsh or nu, verify the binary is installed and on PATH, and that running the profile query command manually succeeds
- Correct the `name` field to a supported shell (bash, zsh, fish, pwsh, nu, elvish, xonsh, yash)
Example fix
// before: pwsh not installed
{ "name": "pwsh", "command": "oh-my-posh init pwsh" }
// after: install PowerShell or use the shell you actually run
{ "name": "zsh", "command": "oh-my-posh init zsh" } Defensive patterns
Strategy: validation
Validate before calling
if os.Getenv("HOME") == "" && runtime.GOOS != "windows" {
return fmt.Errorf("HOME is not set; shell config path cannot be resolved")
}
supported := []string{"bash","zsh","fish","pwsh","nu","elvish","xonsh","yash"}
if !slices.Contains(supported, shellName) {
return fmt.Errorf("unsupported shell name %q", shellName)
}
if shellName == "pwsh" || shellName == "nu" {
if _, err := exec.LookPath(shellName); err != nil {
return fmt.Errorf("%s binary not on PATH", shellName)
}
} Try / catch
if err := sh.Apply(); err != nil {
if strings.Contains(err.Error(), "failed to get shell config path") {
return fmt.Errorf("check HOME, shell name (%q), and that pwsh/nu is installed: %w", sh.Name, err)
}
return err
} Prevention
- Always run in an environment with HOME set (containers: pass -e HOME=...)
- Install pwsh/nu when the DSC document names those shells
- Keep the `name` field in sync with the shell you actually use
- Unwrap the %w error first; it distinguishes home-dir, command, and unsupported-shell causes
When it happens
Trigger: Applying a DSC Shell resource when getShellConfigPath fails: HOME is unset/unresolvable, the `pwsh -NoProfile -Command $PROFILE` or `nu -c $nu.config-path` command fails or the binary is absent, or the shell name is not one of the supported constants.
Common situations: Running in a container/CI where HOME is not set; PowerShell not on PATH when name is pwsh; nu not installed when name is nu; a typoed or custom shell name in the DSC document.
Related errors
- failed to get home directory
- unsupported shell type: %s
- environment access is disabled: rendering from recorded data
- terminal width must be greater than zero
- source file %s does not match format %s
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/27d844d780004a28.
Report an issue: GitHub.