{"record":{"id":"83707345abecc3f0","repo":"yorukot/superfile","slug":"could-not-read-user-s-theme-file-s-err-w","errorCode":null,"errorMessage":"could not read user's theme file(%s), err : %w","messagePattern":"could not read user's theme file\\((.+?)\\), err : %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/internal/common/load_config.go","lineNumber":215,"sourceCode":"\t\t\tutils.PrintfAndExitf(\"Unexpected error while reading default theme file : %v. Exiting...\", err)\n\t\t}\n\t}\n\n\t// Validations\n\tif len(Theme.GradientColor) != RequiredGradientColorCount {\n\t\tutils.PrintlnAndExit(\n\t\t\tLoadThemeError(\n\t\t\t\t\"gradient_color\",\n\t\t\t\t\"Gradient color must contain exactly two values.\",\n\t\t\t),\n\t\t)\n\t}\n}\n\nfunc LoadUserTheme(themeFile string, obj *ThemeType) error {\n\tdata, err := os.ReadFile(themeFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not read user's theme file(%s), err : %w\", themeFile, err)\n\t}\n\tif err = toml.Unmarshal(data, obj); err != nil {\n\t\treturn fmt.Errorf(\"could not unmarshal user's theme file(%s) : %w\", themeFile, err)\n\t}\n\treturn nil\n}\n\n// LoadAllDefaultConfig : Load all default configurations from embedded superfile_config folder into global\n// configurations variables and write theme files if its needed.\nfunc LoadAllDefaultConfig(content embed.FS) {\n\terr := LoadConfigStringGlobals(content)\n\tif err != nil {\n\t\tslog.Error(\"Could not load default config from embed FS\", \"error\", err)\n\t\treturn\n\t}\n\n\tcurrentThemeVersion, err := os.ReadFile(variable.ThemeFileVersion)\n\tif err != nil && !os.IsNotExist(err) {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/yorukot/superfile/blob/b72f550bc6e75913f48eb49fdd258e1a2df2fe88/src/internal/common/load_config.go#L197-L233","documentation":"LoadUserTheme reads a user theme file from disk and wraps any os.ReadFile failure with this message. It is thrown when the theme file cannot be read at all (as opposed to failing to parse). The wrapped error (%w) contains the underlying os error such as ENOENT or EACCES.","triggerScenarios":"LoadThemeFile calls LoadUserTheme(themeFile, obj) and os.ReadFile(themeFile) returns an error: the file does not exist, permission is denied, or the path is a directory.","commonSituations":"User set a custom theme name in config but never created the corresponding ~/.config/superfile/theme/<name>.toml file; a typo in the theme path; file deleted or moved by another tool; restrictive file permissions after a dotfiles sync.","solutions":["Check that the theme file path printed in the error actually exists (ls the path).","Set the theme in config to a name matching an existing file in the themes directory, or create the file.","Fix file permissions (chmod 644) or ownership on the theme file.","Verify the path is a regular file, not a directory."],"exampleFix":"// before\ntheme = 'my-custom-theme' // file never created\n// after\ntheme = 'catppuccin' // matches ~/.config/superfile/theme/catppuccin.toml","handlingStrategy":"validation","validationCode":"if st, err := os.Stat(themeFile); err != nil {\n    return fmt.Errorf(\"theme file %q not accessible: %w\", themeFile, err)\n} else if st.IsDir() {\n    return fmt.Errorf(\"theme path %q is a directory\", themeFile)\n}","typeGuard":"func themeFileReadable(path string) bool {\n    f, err := os.Open(path)\n    if err != nil { return false }\n    f.Close()\n    return true\n}","tryCatchPattern":"if err := common.LoadUserTheme(themeFile, &theme); err != nil {\n    var pErr *fs.PathError\n    if errors.As(err, &pErr) && errors.Is(pErr.Err, fs.ErrNotExist) {\n        log.Warnf(\"theme %q missing, using default\", themeFile)\n        return common.LoadDefaultTheme()\n    }\n    return err\n}","preventionTips":["Ship/verify default theme files on first run before referencing them by name.","Validate the theme path exists at config-load time, not deep in the UI.","Never construct theme paths by string concatenation without filepath.Join.","Watch theme dirs for external deletions if you cache the config."],"tags":["config","theme","file-io","path"],"backgroundTag":"file-not-found","analyzedSha":"b72f550bc6e75913f48eb49fdd258e1a2df2fe88","analyzedAt":"2026-09-01T04:38:08.254Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}