Repository: eza-community/eza (language: rust)

Issue:
bug: After the last update, the themes are not working.
If eza does something unexpected, or its output looks wrong, or it displays an error on the screen, or if it outright crashes, then please include the following information in your report:

- The version of eza being used (`eza --version`)
- The command-line arguments you are using
- Your shell and terminal
- Your operating system and hardware platform

If it’s a crash, please include the full text of the crash that gets printed to the screen. If you’re seeing unexpected behaviour, a screenshot of the issue will help a lot.

---
Win 11, terminal 1.22, powershell 7.4.6, eza v0.20.18 


Discussion / hints:
I believe it's a regression from https://github.com/eza-community/eza/pull/1328. If you have `EZA_CONFIG_DIR` set in PowerShell, there is a workaround https://github.com/eza-community/eza-themes/discussions/7#discussioncomment-11956698, which works for me.
> I believe it's a regression from [#1328](https://github.com/eza-community/eza/pull/1328). If you have `EZA_CONFIG_DIR` set in PowerShell, there is a workaround [eza-community/eza-themes#7 (comment)](https://github.com/eza-community/eza-themes/discussions/7#discussioncomment-11956698), which works for me.

Works. Thank you for your help.

Fix patch:
diff --git a/src/options/config.rs b/src/options/config.rs
index 74b00c8c1..ea4248fb5 100644
--- a/src/options/config.rs
+++ b/src/options/config.rs
@@ -12,17 +12,21 @@ use serde_norway;
 use std::collections::HashMap;
 use std::path::PathBuf;
 
-#[derive(Debug, Default, Eq, PartialEq)]
+#[derive(Debug, Eq, PartialEq)]
 pub struct ThemeConfig {
     // This is rather bare for now, will be expanded with config file
-    location: ConfigLoc,
+    location: PathBuf,
 }
 
-#[derive(Debug, Default, PartialEq, Eq)]
-pub enum ConfigLoc {
-    #[default]
-    Default, // $XDG_CONFIG_HOME/eza/config|theme.yml
-    Env(PathBuf), // $EZA_CONFIG_DIR
+impl Default for ThemeConfig {
+    fn default() -> Self {
+        ThemeConfig {
+            location: dirs::config_dir()
+                .unwrap_or_default()
+                .join("eza")
+                .join("theme.yml"),
+        }
+    }
 }
 
 trait FromOverride<T>: Sized {
@@ -600,23 +604,13 @@ impl FromOverride<UiStylesOverride> for UiStyles {
     }
 }
 impl ThemeConfig {
-    pub fn from_path(path: &str) -> Self {
-        let path = PathBuf::from(path);
-        ThemeConfig {
-            location: ConfigLoc::Env(path),
-        }
+    pub fn from_path(path: PathBuf) -> Self {
+        ThemeConfig { location: path }
     }
     pub fn to_theme(&self) -> Option<UiStyles> {
-        let ui_styles_override: Option<UiStylesOverride> = match &self.location {
-            ConfigLoc::Default => {
-                let path = dirs::config_dir()?.join("eza").join("theme.yml");
-                let file = std::fs::File::open(path).ok()?;
-                serde_norway::from_reader(&file).ok()
-            }
-            ConfigLoc::Env(path) => {
-                let file = std::fs::File::open(path).ok()?;
-                serde_norway::from_reader(&file).ok()
-            }
+        let ui_styles_override: Option<UiStylesOverride> = {
+            let file = std::fs::File::open(&self.location).ok()?;
+            serde_norway::from_reader(&file).ok()
         };
         FromOverride::from(ui_styles_override, Some(UiStyles::default()))
     }
diff --git a/src/options/theme.rs b/src/options/theme.rs
index 157eec991..ba60a7957 100644
--- a/src/options/theme.rs
+++ b/src/options/theme.rs
@@ -35,26 +35,30 @@ impl Options {
 
 impl ThemeConfig {
     fn deduce<V: Vars>(vars: &V) -> Option<Self> {
-        let (base_path, is_default_location) = if let Some(path) = vars.get("EZA_CONFIG_DIR") {
-            (PathBuf::from(path), false)
-        } else if let Some(path) = dirs::config_dir() {
-            (path.join("eza"), true)
+        if let Some(path) = vars.get("EZA_CONFIG_DIR") {
+            let path = PathBuf::from(path);
+            let theme = path.join("theme.yml");
+            if theme.exists() {
+                return Some(ThemeConfig::from_path(theme));
+            }
+            let theme = path.join("theme.yaml");
+            if theme.exists() {
+                return Some(ThemeConfig::from_path(theme));
+            }
+            None
         } else {
-            return None;
-        };
-        let yml_path = base_path.join("theme.yml");
-        if yml_path.exists() {
-            return if is_default_location {
-                Some(ThemeConfig::from_path(&yml_path.to_string_lossy()))
-            } else {
-                Some(ThemeConfig::default())
-            };
-        }
-        let yaml_path = base_path.join("theme.yaml");
-        if yaml_path.exists() {
-            return Some(ThemeConfig::from_path(&yaml_path.to_string_lossy()));
+            let path = dirs::config_dir().unwrap_or_default();
+            let path = path.join("eza");
+            let theme = path.join("theme.yml");
+            if theme.exists() {
+                return Some(ThemeConfig::default());
+            }
+            let theme = path.join("theme.yaml");
+            if theme.exists() {
+                return Some(ThemeConfig::from_path(theme));
+            }
+            None
         }
-        None
     }
 }
 


Test patch: