gitui icon indicating copy to clipboard operation
gitui copied to clipboard

Theme file not loading on macOS

Open maxhoffmann opened this issue 1 year ago • 3 comments
trafficstars

Describe the bug When I override the default theme or try to add a new one, it doesn’t affect gitui’s theme.

To Reproduce Steps to reproduce the behavior:

  1. Install gitui via brew
  2. Add a theme at ~/.config/gitui/theme.ron
  3. Example theme:
(
    line_break: Some(""),
    selection_bg: Some(LightBlue),
)
  1. Open gitui
  2. Colors are still the same and new line operator is still visible.

Expected behavior I expect the theme to change.

Context (please complete the following information):

  • OS/Distro + Version: macOS 13.6.3
  • GitUI Version 0.24.3

Additional context It would help to see where themes are loaded from, in case gitui doesn’t use ~/.config/gitui/. Trying to add a custom theme and loading it via -t also doesn’t lead to any error. It silently fails, so I cannot debug where the gitui loads the themes from.

maxhoffmann avatar Jan 12 '24 10:01 maxhoffmann

just tried and on master aswell on the version you use via brew exactly your theme changes work as expected.

extrawurst avatar Jan 12 '24 12:01 extrawurst

@extrawurst Is there any way to tell gitui that it should log which themes it loads and in which folder it looks? This would really help debugging this on my machine.

maxhoffmann avatar Jan 12 '24 12:01 maxhoffmann

please run with -l to enable logging, see https://github.com/extrawurst/gitui#diagnostics

and share the log created. also helpful is checking if echo $HOME and echo ~ return the right user folder where you store the config

extrawurst avatar Jan 12 '24 13:01 extrawurst

@maxhoffmann still an issue? any findings via the log option?

extrawurst avatar Feb 18 '24 13:02 extrawurst

@extrawurst unfortunately yes. there are no entries in the log file about loading a config. echo $HOME and echo ~ return the correct path

maxhoffmann avatar Feb 18 '24 14:02 maxhoffmann

@maxhoffmann can you please try to build from source? in be10d9096a93b030ec3f1ab776a21225d974e272 I added logging theme loading errors to the logfile

extrawurst avatar Feb 19 '24 11:02 extrawurst

I experience a similar issue.

The logging added in be10d90 does not seem sufficient to debug this issue, since it does not print WHICH theme is loaded.

cgahr avatar Feb 19 '24 16:02 cgahr

@cgahr please try again with current master (f0f90a8) which should also print the path of the theme that errors

extrawurst avatar Feb 19 '24 20:02 extrawurst

I can confirm the -t <path> and --theme <path> both have no effect.

To reproduce:

  1. remove last ) from ~/.config/gitui/theme.ron so that the resulting config is not a valid .ron file
  2. run ./target/debug/gitui -l -t doesnotexist

The relevant line in the log file is

06:31:53 [ERROR] theme error ["/home/cgahr/.config/gitui/theme.ron"]: 28:1: Unexpected end of RON

As you can see, gitui is complaining that the config is not valid (which it is correct because I broke it), however, it should complain that the theme doesntexist does not exist. Instead, as far as I can tell, it doesn't even try to read the file.

cgahr avatar Feb 20 '24 06:02 cgahr

i think i know where the confustion comes from. the provided parameter is a filename, not a path. right now you cannot change the path but only the filename that's loaded from the config path.

plus it silently fallback the default theme file name if the provided one is not a valid filename in that config path

extrawurst avatar Feb 20 '24 14:02 extrawurst

please test the version in the PR #2077

extrawurst avatar Feb 20 '24 14:02 extrawurst

I see, that explains why I wasn't able to change the theme, it was not in the config folder! I can confirm that -t <file-in-config-dir> works as intended then.

However, #2077 doesn't work correctly, I don't get a log entry if I try to use a nonexistent theme.

cgahr avatar Feb 20 '24 15:02 cgahr

now with da610e7 it works for me: gitui -t foo.bar logs: 15:52:49 [ERROR] theme error ["/Users/stephan/.config/gitui/foo.bar"]: No such file or directory (os error 2)

extrawurst avatar Feb 20 '24 15:02 extrawurst

@cgahr @maxhoffmann I think this improves the diagnostics a lot, there is an argument to be made if one should not be able to define a full theme path. but that's a story for another day

extrawurst avatar Feb 20 '24 17:02 extrawurst

I can confirm, at da610e7 every works now correctly. I think you can close this issue.

cgahr avatar Feb 20 '24 17:02 cgahr