atuinsh/atuin · error · std::io::Error

Empty theme directory override and could not find theme…

Error message

Empty theme directory override and could not find theme elsewhere

What it means

When loading a theme, if the user configured an override_theme_dir but the configured string is empty, Atuin cannot resolve the theme file location and immediately returns this NotFound error instead of silently falling back to the default theme search path.

Solutions

  1. Set override_theme_dir to a valid existing directory containing your themes, or remove the override entirely so Atuin uses default search paths.
  2. If the value comes from an env var or template, check it resolves non-empty before writing the config.
  3. Verify the config file (e.g. ~/.config/atuin/config.toml) has a non-empty theme directory value.

Example fix

# before (config.toml)
override_theme_dir = ""

# after
override_theme_dir = "/home/me/.config/atuin/themes"
Defensive patterns

Strategy: validation

Validate before calling

let dir = &settings.theme.override_theme_dir;
if let Some(d) = dir {
    if d.is_empty() {
        eprintln!("override_theme_dir is set but empty; fix config.toml or remove it");
        std::process::exit(1);
    }
    if !std::path::Path::new(d).is_dir() {
        eprintln!("override_theme_dir '{d}' does not exist");
    }
}

Type guard

fn has_valid_theme_override(cfg: &Settings) -> bool {
    cfg.theme
        .override_theme_dir
        .as_deref()
        .map(|d| !d.is_empty())
        .unwrap_or(true) // no override is fine
}

Try / catch

match theme_engine.load_theme(name, 3) {
    Ok(t) => apply(t),
    Err(e) if e.to_string().contains("Empty theme directory override") => {
        eprintln!("config: override_theme_dir is empty; falling back to default theme");
        apply(default_theme());
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling load_theme (-> load_theme_from_file) when the config sets an override theme directory to an empty string, e.g. `theme_dir = ""` or an env-derived value that resolved to empty.

Common situations: Config templating that yields an empty value (unset env var interpolated as ""), a copy-pasted config with the setting blanked, or programmatic construction of a ThemeConfig with the default empty string left in place.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19). Data as JSON: /api/errors/8979e16f11f50306. Report an issue: GitHub.

Appendix: source

Thrown at crates/atuin-client/src/theme.rs:389

            loaded_themes: HashMap::new(),
            debug: debug.unwrap_or(false),
            override_theme_dir: match theme_dir {
                Some(theme_dir) => Some(theme_dir),
                None => std::env::var("ATUIN_THEME_DIR").ok(),
            },
        }
    }

    // Try to load a theme from a `{name}.toml` file in the theme directory. If an override is set
    // for the theme dir (via ATUIN_THEME_DIR env) we should load the theme from there
    pub fn load_theme_from_file(
        &mut self,
        name: &str,
        max_depth: u8,
    ) -> Result<&Theme, Box<dyn error::Error>> {
        let mut theme_file = if let Some(p) = &self.override_theme_dir {
            if p.is_empty() {
                return Err(Box::new(Error::new(
                    ErrorKind::NotFound,
                    "Empty theme directory override and could not find theme elsewhere",
                )));
            }
            PathBuf::from(p)
        } else {
            let config_dir = atuin_common::utils::config_dir();
            let mut theme_file = if let Ok(p) = std::env::var("ATUIN_CONFIG_DIR") {
                PathBuf::from(p)
            } else {
                let mut theme_file = PathBuf::new();
                theme_file.push(config_dir);
                theme_file
            };
            theme_file.push("themes");
            theme_file
        };

View on GitHub (pinned to 900007c480)