A GTK configuration screen complaining about a missing icon cache file on Peppermint Linux
A GTK configuration screen complaining about a missing icon cache file on Peppermint Linux

If you see some widget or configuration dialog in Linux,  complaining about the fact that your icon cache files are missing, here’s how you can easily fix it.

Using the manual method, or folder-by-folder method that is displayed in the small tooltip on the image, is cumbersome, and if you have a lot of icons that have missing cache files, it can take up a lot of time and would force you to do a lot of unnecessary typing.

*see update at the end*

The simplest way to regenerate all the icon cache files, is to use bash commands to parse the icon directories on the system into a variable, and then pass that variable’s content into another command as an argument, to regenerate the caches both in the system-wide /usr/share/icons folder’s subfolders, and in your home directory’s .icons folder’s subfolders, if you have some.

Here’s a snippet I’m using on peppermint;

 

for i in $(find /usr/share/icons/ -maxdepth 1 -type d); do sudo rm -f $i/.icon-theme.cache; sudo gtk-update-icon-cache -t -i $i; done

for i in $(find ~/.icons -maxdepth 1 -type d); do sudo rm -f $i/.icon-theme.cache; sudo gtk-update-icon-cache -t -i $i; done

You can easily save the code part to a file, like “regeniconcache”, to whatever directory you want, and then make it executable by typing this in the terminal (in the same folder where you’ve saved the file)

chmod 755 ~/regeniconcache

and then put it into the user-executable scripts folder by typing this into the terminal :

sudo ln -sf ~/regeniconcache /usr/sbin/regeniconcache

Every time you notice that some widget complains that there’s an icon cache file missing, you can simply type

regeniconcache

into the terminal and press enter, and the entire icon cache will be regenerated.

This should work on almost all versions of ubuntu, linux mint, peppermint linux, and similar ubuntu derivatives / flavors / offshoots.

*update*

If you are on a peppermint 8 or other linux mint flavour, or ubuntu flavour that doesn’t have the command “gtk-update-icon-cache”, add the “update-icon-caches” program as a linked command, by typing this into the terminal :

sudo ln -sf /usr/sbin/update-icon-caches /usr/sbin/gtk-update-icon-cache

Afterwards, you can run the same “regeniconcache” bash script, as described above.

Leave a Reply