Could not load a pixbuf无法识别的图像文件格式 (gdk-pixbuf-error-quark, 3)
2022年7月7日大约 1 分钟
上一级页面:index-wsl
前言
运行GUI程序出现报错如下,
(gnome-calculator:4038): Gtk-WARNING **: 06:23:42.942: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
**
Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /usr/share/icons/Yaru/16x16/status/image-missing.png: Unrecognized image file format (gdk-pixbuf-error-quark, 3)
Bail out! Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /usr/share/icons/Yaru/16x16/status/image-missing.png: Unrecognized image file format (gdk-pixbuf-error-quark, 3)
[1] 4038 abort (core dumped) gnome-calculator
解决方案
就像报错信息所提示的那样
This may indicate that pixbuf loaders or the mime database could not be found.
我们从gtk3、gdk-pixbuf、mime database等几个方向进行排查
首先检查XDG_DATA_DIRS
,确保不要在.zshrc
(或bashrc等)中设置XDG_DATA_DIRS
,
不要在XDG_DATA_DIRS
中包含flatpak的path
echo $XDG_DATA_DIRS
的一个参考结果如下
/home/user/snap/alacritty/46/.local/share:/home/user/snap/alacritty/46:/snap/alacritty/46/usr/share:/usr/share/awesome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
重新安装一些包,并且重新配置,并且标记为自动安装
sudo apt install --reinstall libgdk-pixbuf2.0-0
sudo apt install --reinstall shared-mime-info
sudo apt install --reinstall libgtk-3-common
sudo dpkg-reconfigure libgdk-pixbuf2.0-0
sudo dpkg-reconfigure shared-mime-info
sudo dpkg-reconfigure libgtk-3-common
sudo apt-mark auto libgdk-pixbuf2.0-0 shared-mime-info libgtk-3-common
更新mime-database
sudo update-mime-database /usr/share/mime
参考、引用、致谢
gnome - Gtk-WARNING **: Could not load a pixbuf from icon theme - Ask Ubuntu
https://bbs.archlinux.org/viewtopic.php?id=245985
https://unix.stackexchange.com/questions/505063/how-to-repair-broken-permissions-on-files-in-usr-share-mime