From ff1c62eacba2d198df914aa07b4ef20e49ca344c Mon Sep 17 00:00:00 2001 From: umut-polat <52835619+umut-polat@users.noreply.github.com> Date: Sat, 28 Mar 2026 11:47:13 +0000 Subject: [PATCH] fix: skip home-based config paths when $HOME is not set When $HOME is not defined, os.UserHomeDir returns an error. Previously this caused readFxrc to return an error, which panicked in init(). Instead, skip the home-based paths (~/.fxrc.js and ~/.config/fx/.fxrc.js) when the home directory is unavailable. XDG_CONFIG_HOME is still honored if explicitly set. Fixes #397 --- internal/engine/fxrc.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/engine/fxrc.go b/internal/engine/fxrc.go index a24539717..6f3b29bf0 100644 --- a/internal/engine/fxrc.go +++ b/internal/engine/fxrc.go @@ -18,16 +18,17 @@ func readFxrc() (string, error) { paths := []string{filepath.Join(cwd, ".fxrc.js")} home, err := os.UserHomeDir() - if err != nil { - return "", fmt.Errorf("get home: %w", err) + if err == nil { + paths = append(paths, filepath.Join(home, ".fxrc.js")) } - paths = append(paths, filepath.Join(home, ".fxrc.js")) xdgHome := os.Getenv("XDG_CONFIG_HOME") - if xdgHome == "" { + if xdgHome == "" && home != "" { xdgHome = filepath.Join(home, ".config") } - paths = append(paths, filepath.Join(xdgHome, "fx", ".fxrc.js")) + if xdgHome != "" { + paths = append(paths, filepath.Join(xdgHome, "fx", ".fxrc.js")) + } xdgDirs := os.Getenv("XDG_CONFIG_DIRS") if xdgDirs == "" {