epi052/feroxbuster · error · anyhow::Error

Couldn't load config

Error message

Couldn't load config

What it means

parse_config_files needs the user's OS config directory (via the dirs crate) to locate ~/.config/feroxbuster/ferox-config.toml. If dirs::config_dir() returns None — meaning HOME/XDG or the platform equivalent cannot be resolved — the function bails with this error rather than silently skipping default config discovery.

Solutions

  1. Set the HOME environment variable (Linux/macOS) or ensure the user profile exists before running
  2. Set XDG_CONFIG_HOME to an existing writable directory as an alternative
  3. Report this as a bug if the environment has a valid HOME yet the error persists

Example fix

// before (shell)
feroxbuster -u http://host # container with HOME unset
// after (shell)
HOME=/root feroxbuster -u http://host
Defensive patterns

Strategy: fallback

Validate before calling

let home_ok = std::env::var_os("HOME").is_some() || std::env::var_os("XDG_CONFIG_HOME").is_some();
if !home_ok { eprintln!("set HOME or XDG_CONFIG_HOME"); }

Type guard

fn config_dir_available() -> bool { dirs::config_dir().is_some() }

Try / catch

match config.parse_config_files() { Err(e) if e.to_string().contains("Couldn't load config") => eprintln!("no config dir resolvable; set HOME/XDG_CONFIG_HOME"), Err(e) => return Err(e), Ok(_) => {} }

Prevention

When it happens

Trigger: Calling Configuration::parse_config_files (directly or via startup) in an environment where dirs::config_dir() yields None: HOME unset on Linux, or no roaming-app-data directory resolvable on Windows/macOS.

Common situations: Running feroxbuster in a container or CI job with no HOME set, running under a service account with no profile, or a stripped sandbox environment.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of epi052/feroxbuster@1f595dab5c (2026-09-13). Data as JSON: /api/errors/58ef666be09667da. Report an issue: GitHub.

Appendix: source

Thrown at src/config/container.rs:653

        // in the Configuration struct so that we don't change anything that isn't
        // actually specified in the config file
        //
        // search for a config using the following order of precedence
        //   - /etc/feroxbuster/
        //   - CONFIG_DIR/ferxobuster/
        //   - same directory as feroxbuster executable
        //   - current directory

        // merge a config found at /etc/feroxbuster/ferox-config.toml
        let config_file = Path::new("/etc/feroxbuster").join(DEFAULT_CONFIG_NAME);
        Self::parse_and_merge_config(config_file, config)?;

        // merge a config found at ~/.config/feroxbuster/ferox-config.toml
        // config_dir() resolves to one of the following
        //   - linux: $XDG_CONFIG_HOME or $HOME/.config
        //   - macOS: $HOME/Library/Application Support
        //   - windows: {FOLDERID_RoamingAppData}
        let config_dir = dirs::config_dir().ok_or_else(|| anyhow!("Couldn't load config"))?;
        let config_file = config_dir.join("feroxbuster").join(DEFAULT_CONFIG_NAME);
        Self::parse_and_merge_config(config_file, config)?;

        // merge a config found in same the directory as feroxbuster executable
        let exe_path = current_exe()?;
        let bin_dir = exe_path
            .parent()
            .ok_or_else(|| anyhow!("Couldn't load config"))?;
        let config_file = bin_dir.join(DEFAULT_CONFIG_NAME);
        Self::parse_and_merge_config(config_file, config)?;

        // merge a config found in the user's current working directory
        let cwd = current_dir()?;
        let config_file = cwd.join(DEFAULT_CONFIG_NAME);
        Self::parse_and_merge_config(config_file, config)?;

        Ok(())
    }

View on GitHub (pinned to 1f595dab5c)