On F41, for an ordinary used, mesa_shader_cache gets created owned by root

After upgrading to Fedora 41, I noticed that upon starting X as an ordinary user, I have ~/.cache/mesa_shader_cache created to be owned by root (and with the group of given user). I assume that should not be the case, any idea how to debug or fix the problem? Please note that my setup is somewhat non-standard: I’m using Fedora Scientific Lab, my window manager is Openbox, and I’m starting X through startx command. I can provide config/log files that could be relevant to the problem, but I still think this issue should not happen.

Thanks.

You can simply delete the directory and reboot, without starting any other applications, to check whether it’s the base system that creates the directory.

If it isn’t recreated on the next login, then it was likely created by a userspace application. In that case the directory could not have been created as root without an application asking you to raise privileges (via a password prompt) or if the application was running under a root node – for example in a container (flatpak/docker/etc) that was launched as root or with certain root privileges.

As mentioned in my first message, this file is re-created whenever I start the X server. Actually, the problem is more serious than I thought initially, as if there is no ~/.cache directory, then this directory is created to be owned by root user, and any other application cannot use it, so various problem occurs, for example Firefox won’t even start. I did not encountered this kind of a problem initially as I have XDG_CACHE_HOME environment variable pointing to a different directory. So there are actually two issues here:

  1. Whatever creates mesa_shader_cache is not respecting XDG_CACHE_HOME, and that seems to be known issue.
  2. Whatever creates mesa_shader_cache is wrongly doing it in the user home directory, but with a root privileges. And I think this has to be something within X server, as it happens when X started, and X is the only program acquiring root privileges, in order to create screen.

You can force the cache directory on a per user basis by using a local environment file. For this you would create a file in the ~/.config/environment.d directory, for example:

~/.config/environment.d/00-shader_cache.conf

MESA_SHADER_CACHE_DIR=/home/<your_username>/.cache/mesa_shader_cache_db

Thank you for your reply.

It is something between Xorg and Intel graphics driver. I have dual GPU laptop, with NVIDIA and Intel cards, and when I force NVIDIA card to be used, the problem doesn’t occur. Also, the problem doesn’t occur if I start a Wayland compositor, for example labwc, instead of Xorg, no matter which card used. But, when Intel card used with Xorg, even if I set MESA_SHADER_CACHE_DIR environment variable per your suggestion, ~/.cache/mesa_shader_cache is still created and owned by root upon Xorg started. When I start another program, for example Firefox, that writes to the shader cache directory, it obeys MESA_SHADER_CACHE_DIR setting. Thus, probably ~/.cache/mesa_shader_cache is hard-coded somewhere in the Intel driver, so it ignores both XDG_CACHE_HOME and MESA_SHADER_CACHE_DIR - so I’d still call it a bug.

While debugging a different issue, it turned out that my xinitrc file has number of issues, so I switched to using a display manager. The issue with the shader cache directory permissions disappeared afterwards - now it’s created properly, with the regular user as owner. Sorry for the inconvenience, and thanks for the help.