{"record":{"id":"27d844d780004a28","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-get-shell-config-path-w","errorCode":null,"errorMessage":"failed to get shell config path: %w","messagePattern":"failed to get shell config path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dsc/shell.go","lineNumber":68,"sourceCode":"\n\treturn s.Name == other.Name\n}\n\nfunc (s *Shell) Resolve() (*Shell, bool) {\n\treturn nil, false\n}\n\nfunc (s *Shell) Apply() error {\n\tif s.Command == \"\" {\n\t\treturn nil\n\t}\n\n\tlog.Debug(\"applying shell configuration with command: %s\", s.Command)\n\n\t// Get the shell configuration file path\n\tconfigPath, err := s.getShellConfigPath()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get shell config path: %w\", err)\n\t}\n\n\tif err := s.validateShellConfigPath(configPath); err != nil {\n\t\treturn err\n\t}\n\n\t// Read current configuration\n\tcontent, err := os.ReadFile(configPath)\n\tif err != nil {\n\t\tlog.Debug(\"failed to read shell config file\")\n\t\treturn err\n\t}\n\n\tcontentStr, updated := s.updateShellConfig(string(content))\n\tif !updated {\n\t\tlog.Debug(\"shell config already up to date, skipping write\")\n\t\treturn nil\n\t}","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/dsc/shell.go#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before: pwsh not installed\n{ \"name\": \"pwsh\", \"command\": \"oh-my-posh init pwsh\" }\n// after: install PowerShell or use the shell you actually run\n{ \"name\": \"zsh\", \"command\": \"oh-my-posh init zsh\" }","handlingStrategy":"validation","validationCode":"if os.Getenv(\"HOME\") == \"\" && runtime.GOOS != \"windows\" {\n    return fmt.Errorf(\"HOME is not set; shell config path cannot be resolved\")\n}\nsupported := []string{\"bash\",\"zsh\",\"fish\",\"pwsh\",\"nu\",\"elvish\",\"xonsh\",\"yash\"}\nif !slices.Contains(supported, shellName) {\n    return fmt.Errorf(\"unsupported shell name %q\", shellName)\n}\nif shellName == \"pwsh\" || shellName == \"nu\" {\n    if _, err := exec.LookPath(shellName); err != nil {\n        return fmt.Errorf(\"%s binary not on PATH\", shellName)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := sh.Apply(); err != nil {\n    if strings.Contains(err.Error(), \"failed to get shell config path\") {\n        return fmt.Errorf(\"check HOME, shell name (%q), and that pwsh/nu is installed: %w\", sh.Name, err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["dsc","shell","config-path","environment"],"backgroundTag":"shell-config-path-lookup-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}