antonmedv/fx · error

read %s: %w

Error message

read %s: %w

What it means

Wraps an os.ReadFile failure for an existing .fxrc.js config file discovered on the search path (cwd, home, XDG_CONFIG_HOME, XDG_CONFIG_DIRS). The file passed the Stat check but could not be read, typically due to permission denial or an I/O error, so rc-file loading aborts.

Source

Thrown at internal/engine/fxrc.go:49

	}

	xdgDirs := os.Getenv("XDG_CONFIG_DIRS")
	if xdgDirs == "" {
		xdgDirs = "/etc/xdg"
	}
	for _, dir := range strings.Split(xdgDirs, ":") {
		paths = append(paths, filepath.Join(dir, "fx", ".fxrc.js"))
	}

	// Read and combine
	for _, path := range uniq(paths) {
		info, err := os.Stat(path)
		if err != nil || info.IsDir() {
			continue // skip missing or directories
		}
		data, err := os.ReadFile(path)
		if err != nil {
			return "", fmt.Errorf("read %s: %w", path, err)
		}
		builder.Write(data)
		builder.WriteString("\n")
	}

	return builder.String(), nil
}

func uniq(paths []string) []string {
	seen := make(map[string]bool)
	result := []string{}
	for _, path := range paths {
		if !seen[path] {
			seen[path] = true
			result = append(result, path)
		}
	}
	return result

View on GitHub (pinned to 4f31cd3a0c)

Solutions

  1. Fix permissions on the named file (chmod/chown)
  2. Remove the unreadable .fxrc.js if it is no longer needed
  3. Run fx with a XDG_CONFIG_DIRS that excludes the broken path
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/engine/fxrc.go:49 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of antonmedv/fx@4f31cd3a0c (2026-09-02). Data as JSON: /api/errors/28de4dbfcf3daf9f. Report an issue: GitHub.