kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.82k stars 961 forks source link

using `kitten themes --reload-in=all` no longer changes theme of open windows when using nix home manager. #7825

Closed shot-codes closed 1 week ago

shot-codes commented 1 week ago

Describe the bug When I issue a kitten themes --reload-in=all command, I receive the following error:

❯ kitten themes --reload-in=all desert
Error: open /nix/store/snznb8z8dfvx826gxb2035x2c3bxz6zm-hm_kittykitty.conf.atomic-write-3560583081: read-only file system

The theme does not change for open windows but windows created after issuing the command have reflect the theme change.

I'm not sure when this was introduced as I hadn't updated my system in ~2 months. I do think it was a regression though as live changing themes of existing windows worked before the update. I use nix home manager to manage my kitty config and AFAIK there hasn't been any major changes that would change this behavior.

To Reproduce Steps to reproduce the behavior:

  1. Use nix home manager to manage kitty config (perhaps be on NixOS?), have a kitty window open.
  2. Issue a kitten themes command with option reload-in=all
  3. See error

Environment details

kitty 0.36.1 created by Kovid Goyal
Linux GLaDOS 6.6.48 #1-NixOS SMP PREEMPT_DYNAMIC Thu Aug 29 15:33:59 UTC 2024 x86_64

<<< Welcome to NixOS 24.11.20240831.12228ff (x86_64) - /dev/tty >>>

Run 'nixos-help' for the NixOS manual.

DISTRIB_CODENAME=vicuna
DISTRIB_DESCRIPTION="NixOS 24.11 (Vicuna)"
DISTRIB_ID=nixos
DISTRIB_RELEASE="24.11"
LSB_VERSION="24.11 (Vicuna)"
Running under: Wayland (/etc/profiles/per-user/shot/bin/Hyprland) missing: single_pixel_buffer
OpenGL: '4.6 (Core Profile) Mesa 24.2.1' Detected version: 4.6
Frozen: False
Fonts:
  medium: IosevkaNF-Bold: /nix/store/vvvfcisirpgspfq51f4njgjv4xh2cj4c-nerdfonts-3.2.1/share/fonts/truetype/NerdFonts/IosevkaNerdFont-Bold.ttf:0
  bold: IosevkaNF-SemiBold: /nix/store/vvvfcisirpgspfq51f4njgjv4xh2cj4c-nerdfonts-3.2.1/share/fonts/truetype/NerdFonts/IosevkaNerdFont-SemiBold.ttf:0
  italic: IosevkaNF-Italic: /nix/store/vvvfcisirpgspfq51f4njgjv4xh2cj4c-nerdfonts-3.2.1/share/fonts/truetype/NerdFonts/IosevkaNerdFont-Italic.ttf:0
  bi: IosevkaNF-SemiBoldItalic: /nix/store/vvvfcisirpgspfq51f4njgjv4xh2cj4c-nerdfonts-3.2.1/share/fonts/truetype/NerdFonts/IosevkaNerdFont-SemiBoldItalic.ttf:0
Paths:
  kitty: /nix/store/b0q4g7wmv8by10l9229vhm04ka432f2h-kitty-0.36.1/bin/kitty
  base dir: /nix/store/b0q4g7wmv8by10l9229vhm04ka432f2h-kitty-0.36.1/lib/kitty
  extensions dir: /nix/store/b0q4g7wmv8by10l9229vhm04ka432f2h-kitty-0.36.1/lib/kitty/kitty
  system shell: /run/current-system/sw/bin/zsh
Loaded config files:
  /home/shot/.config/kitty/kitty.conf

Config options different from defaults:
enable_audio_bell       False
font_family             Iosevka NF Bold
shell_integration       frozenset({'no-rc'})
window_padding_width    FloatEdges(left=4.0, top=4.0, right=4.0, bottom=4.0)
Colors:
    active_border_color     #777777   
    active_tab_background   #f7f7f7   
    background              #ffffff   
    bell_border_color       #e97e57   
    color1                  #aa3731   
    color10                 #60cb00   
    color11                 #ffbc5d   
    color12                 #007acc   
    color13                 #e64ce6   
    color14                 #00aacb   
    color15                 #f7f7f7   
    color2                  #448c37   
    color3                  #cb9000   
    color4                  #325cc0   
    color5                  #7a3e9d   
    color6                  #0083b2   
    color7                  #f7f7f7   
    color8                  #777777   
    color9                  #f05050   
    cursor                  #007acc   
    cursor_text_color       #bfdbfe   
    foreground              #000000   
    inactive_tab_background #dedede   
    selection_background    #bfdbfe   
    url_color               #325cc0   

Important environment variables seen by the kitty process:
    PATH                                /nix/store/b0q4g7wmv8by10l9229vhm04ka432f2h-kitty-0.36.1/bin:/nix/store/b3h3sc5kp7710420zfgn1iifppldi3gh-imagemagick-7.1.1-37/bin:/nix/store/ynmpm3wxvb0sa948fbskwv4hwwx8v65v-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/shot/.nix-profile/bin:/nix/profile/bin:/home/shot/.local/state/nix/profile/bin:/etc/profiles/per-user/shot/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/fg8av6i28rrsxzphyqa1zzrfdvkaxs1h-binutils-wrapper-2.42/bin:/nix/store/q7pkpi9rn5gp5nqgmgwk97lwzn0spyqf-pciutils-3.13.0/bin:/nix/store/p59xamnqd0a6745lqpxfz6i4lp78wwh9-pkgconf-wrapper-2.3.0/bin
    LANG                                en_US.UTF-8
    EDITOR                              nano
    SHELL                               /run/current-system/sw/bin/zsh
    DISPLAY                             :0
    WAYLAND_DISPLAY                     wayland-1
    USER                                shot
    XCURSOR_SIZE                        24
    XDG_CONFIG_DIRS                     /etc/xdg:/home/shot/.nix-profile/etc/xdg:/nix/profile/etc/xdg:/home/shot/.local/state/nix/profile/etc/xdg:/etc/profiles/per-user/shot/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg
    XDG_BACKEND                         wayland
    XDG_SEAT                            seat0
    XDG_SESSION_TYPE                    wayland
    XDG_CURRENT_DESKTOP                 Hyprland
    XDG_VTNR                            1
    XDG_SESSION_ID                      3
    XDG_RUNTIME_DIR                     /run/user/1000
    XDG_DATA_DIRS                       /nix/store/zy7jja2rr1dvih81s02f6ncvbpp9i4ak-desktops/share:/home/shot/.nix-profile/share:/nix/profile/share:/home/shot/.local/state/nix/profile/share:/etc/profiles/per-user/shot/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

Additional context The problem is present with instances run with kitty --config NONE

kovidgoyal commented 1 week ago

you've got your kitty config in a read only filesystem, naturally changing it, which is what's needed, is not going to work.

shot-codes commented 1 week ago

Has this always been the case though? this worked just fine before updating. I've always managed kitty config with home manager which stores the kitty config in a read only filesystem

kovidgoyal commented 1 week ago

Reloading a color theme requires changing the color theme. The color theme is defined in the conf file. It has always been so. If you want to reload colors without changing the conf file use the remote control facility for that, but then any new kitty instances you start will naturally use the old colors.

shot-codes commented 1 week ago

Okay thank you. however the fact the newly opened windows do receive the new color theme suggests that the change is taking place, suggesting an issue with the live-reload

kovidgoyal commented 6 days ago

Read the error message you yourself posted: Error: open /nix/store/snznb8z8dfvx826gxb2035x2c3bxz6zm-hm_kittykitty.conf.atomic-write-3560583081: read-only file system

shot-codes commented 6 days ago

Sorry for the premature comment, and ultimately premature issue. The error message in my original post is actually unrelated and is only encountered in my attempt to make a minimal reproduction. My full setup is as follows:

.config/kitty/
├── current-theme.conf
├── theme.conf
├── kitty.conf -> /nix/store/<hash>-home-manager-files/.config/kitty/kitty.conf
├── theme.conf
└── themes/
    ├── light.conf
    └── dark.conf

Since kitty.conf is indeed in a read-only filesystem, I work around this by including theme.conf in kitty.conf with include /home/shot/.config/kitty/theme.conf. The contents of theme.conf are:

# BEGIN_KITTY_THEME
# Alabaster Custom
include current-theme.conf
# END_KITTY_THEME

I attempt to change themes by calling kitten themes --reload-in=all --cache-age=-1 --config-file-name /home/shot/.config/kitty/theme.conf Alabaster Dark Custom

This doesn't report the error above, as it only changes the contents of theme.conf. The file is written to successfully, and subsequently opened windows reflect the change. However, currently open windows do not change theme.

kovidgoyal commented 5 days ago

I dont really see how that's possible. existing kitty processes are sent the SIGUSR1 signal and reload their config on receipt of that signal. If you can come up with a minimal, non-nix based reproducer for it, I will take a look. I'm afraid setting up nix is way too much overhead for debugging this for me.

shot-codes commented 5 days ago

I'm afraid setting up nix is way too much overhead for debugging this for me.

Totally understandable, I wouldn't expect you to. I will see if I can reproduce outside of nix.

existing kitty processes are sent the SIGUSR1 signal

FYI: I am able to trigger the theme update by manually issuing a SIGUSR1 signal with kill -SIGUSR1 <pid> to any already open kitty window, so I can create a workaround for this. I will see if there is a way for me to debug any further to see what is potentially going wrong with the signal.

Thank you for your help, its much appreciated. Kitty is fantastic