您尚未登录。

#1 2022-08-08 23:58:34

Edsater
会员
注册时间: 2022-07-21
帖子: 20

【已解决】fc-cache报错

$ fc-cache
Fontconfig error: Cannot load default config file

这是什么原因

最近编辑记录 Edsater (2022-08-09 16:26:36)

离线

#2 2022-08-09 00:21:47

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,432
个人网站

Re: 【已解决】fc-cache报错

就这一句报错么?那你检查一下你最近动过的 fontconfig 配置文件呗。

离线

#3 2022-08-09 00:33:01

Edsater
会员
注册时间: 2022-07-21
帖子: 20

Re: 【已解决】fc-cache报错

我最近感觉也没动过,不知道为什么就出错了

$ ls -al /etc/fonts/fonts.conf
-rw-r--r-- 1 root root 2700 Apr 2日 01:30 /etc/fonts/fonts.conf
$ cat /etc/fonts/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
	<description>Default configuration file</description>

<!--
	DO NOT EDIT THIS FILE.
	IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
	LOCAL CHANGES BELONG IN 'local.conf'.

	The intent of this standard configuration file is to be adequate for
	most environments.  If you have a reasonably normal environment and
	have found problems with this configuration, they are probably
	things that others will also want fixed.  Please submit any problems
	to the fontconfig issue tracking system located at fontconfig.org

	Note that the normal 'make install' procedure for fontconfig is to
	replace any existing fonts.conf file with the new version.  Place
	any local customizations in local.conf which this file references.

	Keith Packard
-->

<!-- Font directory list -->

	<dir>/usr/share/fonts</dir>
	<dir>/usr/local/share/fonts</dir>

	
	<dir prefix="xdg">fonts</dir>
	<!-- the following element will be removed in the future -->
	<dir>~/.fonts</dir>

<!--
  Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
	<match target="pattern">
		<test qual="any" name="family">
			<string>mono</string>
		</test>
		<edit name="family" mode="assign" binding="same">
			<string>monospace</string>
		</edit>
	</match>

<!--
  Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
	<match target="pattern">
		<test qual="any" name="family">
			<string>sans serif</string>
		</test>
		<edit name="family" mode="assign" binding="same">
			<string>sans-serif</string>
		</edit>
	</match>

<!--
  Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
	<match target="pattern">
		<test qual="any" name="family">
			<string>sans</string>
		</test>
		<edit name="family" mode="assign" binding="same">
			<string>sans-serif</string>
		</edit>
	</match>
<!--
  Accept alternate 'system ui' spelling, replacing it with 'system-ui'
-->
	<match target="pattern">
		<test qual="any" name="family">
			<string>system ui</string>
		</test>
		<edit name="family" mode="assign" binding="same">
			<string>system-ui</string>
		</edit>
	</match>

<!--
  Load local system customization file
-->
	<include ignore_missing="yes">conf.d</include>

<!-- Font cache directory list -->

	<cachedir>/var/cache/fontconfig</cachedir>
	<cachedir prefix="xdg">fontconfig</cachedir>
	<!-- the following element will be removed in the future -->
	<cachedir>~/.fontconfig</cachedir>

	<config>
<!--
  Rescan configuration every 30 seconds when FcFontSetList is called
 -->
		<rescan>
			<int>30</int>
		</rescan>
	</config>

</fontconfig>

这个文件我目前也不是很看得懂

最近编辑记录 Edsater (2022-08-09 00:33:27)

离线

#4 2022-08-09 10:56:23

Edsater
会员
注册时间: 2022-07-21
帖子: 20

Re: 【已解决】fc-cache报错

依云 说:

就这一句报错么?那你检查一下你最近动过的 fontconfig 配置文件呗。

目前电报群的大哥又让我做了如下处理,但还是没找到问题。

$ sudo fc-cache -fv
Fontconfig error: Cannot load default config file
/usr/share/fonts: caching, new cache contents: 0 fonts, 14 dirs
/usr/share/fonts/TTF: caching, new cache contents: 17 fonts, 0 dirs
/usr/share/fonts/WindowsFonts: caching, new cache contents: 41 fonts, 0 dirs
/usr/share/fonts/adobe-source-code-pro: caching, new cache contents: 30 fonts, 0 dirs
/usr/share/fonts/adobe-source-han-serif: caching, new cache contents: 7 fonts, 0 dirs
/usr/share/fonts/cantarell: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/gnu-free: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/liberation: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/nerd-fonts: caching, new cache contents: 24 fonts, 0 dirs
/usr/share/fonts/noto: caching, new cache contents: 2456 fonts, 0 dirs
/usr/share/fonts/noto-cjk: caching, new cache contents: 80 fonts, 0 dirs
/usr/share/fonts/wenquanyi: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/wenquanyi/wqy-microhei: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts/wenquanyi/wqy-zenhei: caching, new cache contents: 3 fonts, 0 dirs
/usr/share/fonts/wps-fonts: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/wps-office: caching, new cache contents: 1 fonts, 0 dirs
/root/.local/share/fonts: skipping, no such directory
/usr/share/fonts/TTF: skipping, looped directory detected
/usr/share/fonts/WindowsFonts: skipping, looped directory detected
/usr/share/fonts/adobe-source-code-pro: skipping, looped directory detected
/usr/share/fonts/adobe-source-han-serif: skipping, looped directory detected
/usr/share/fonts/cantarell: skipping, looped directory detected
/usr/share/fonts/encodings: skipping, looped directory detected
/usr/share/fonts/gnu-free: skipping, looped directory detected
/usr/share/fonts/liberation: skipping, looped directory detected
/usr/share/fonts/nerd-fonts: skipping, looped directory detected
/usr/share/fonts/noto: skipping, looped directory detected
/usr/share/fonts/noto-cjk: skipping, looped directory detected
/usr/share/fonts/wenquanyi: skipping, looped directory detected
/usr/share/fonts/wps-fonts: skipping, looped directory detected
/usr/share/fonts/wps-office: skipping, looped directory detected
/usr/share/fonts/encodings/large: skipping, looped directory detected
/usr/share/fonts/wenquanyi/wqy-microhei: skipping, looped directory detected
/usr/share/fonts/wenquanyi/wqy-zenhei: skipping, looped directory detected
/build/anaconda/pkg/anaconda/opt/anaconda/var/cache/fontconfig: not cleaning non-existent cache directory
/root/.cache/fontconfig: cleaning cache directory
fc-cache: succeeded
$ pacman -Qkk fontconfig
fontconfig: 346 total files, 0 altered files
$ FC_DEBUG=1024 fc-conflist
FC_DEBUG=1024
Fontconfig error: Cannot load default config file
	Loading config file from memory
	Loading config file from /home/edward/.config/fontconfig/fonts.conf
	Loading config file from /home/edward/.config/fontconfig/fonts.conf done
	Loading config file from memory done
+ /home/edward/.config/fontconfig/fonts.conf: No description
+ memory: No description

离线

#5 2022-08-09 16:26:04

Edsater
会员
注册时间: 2022-07-21
帖子: 20

Re: 【已解决】fc-cache报错

感谢archlinuxcn电报群上依云姐和风语如歌大哥二人的耐心帮助,特别是风语大哥,今天一步一步帮我排查问题,对我这个小白非常有耐心,真的非常感谢,现在我已经解决啦。
问题解决过程:
1.首先风雨大哥先带我做了一下基本的排查,在我上一条评论里已经放出输出结果了,当时并没有头绪。
2.而后依云姐帮我看了用户级和系统级的fonts.conf文件,发现两者也并没有什么问题。
3.依云姐提出要用strace进行问题排查,但我这个小白不太会用,风雨大哥非常耐心的引导我做了如下处理:

$ sudo pacman -S strace
$ strace -o /tmp/log.txt fc-match

这里在/tmp/log.txt中并没有找到 /etc/fonts/fonts.conf相关的信息,发现fontconfig 命令好像是别的软件打包的,因此做了如下验证:

$ /usr/bin/fc-match
NotoSans-Regular.ttf: "Noto Sans" "Regular"

发现系统的fontconfig没有问题,也就是说我目前的fc-* 相关命令不是 /usr/bin/fc-* 里面的而是/opt/anacondda/bin/里的(这个应该是从日志里看出来的),于是看了一下PATH环境变量:

$ echo $PATH
/opt/anaconda/bin:/opt/anaconda/condabin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

发现确实是这样,这让我想起我在.zshrc中好像加过一个和anaconda相关的启动项:

source /opt/anaconda/bin/activate root

应该是这个activate加入了环境变量的设置,把它注释掉来验证一下:

fc-cache

没有任何输出,说明已经成功了,这里风雨大哥建议我把这个设置改用alias来实现,我觉得很有道理,于是我调整为:

alias openconda="source /opt/anaconda/bin/activate root"
alias closeconda="conda deactivate"

经过测试,conda启动关闭正常,fc命令在anaconda未激活下也无报错,至此问题解决。

离线

#6 2022-08-09 17:42:40

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,432
个人网站

Re: 【已解决】fc-cache报错

呃,原来又是 anaconda 搞的鬼……之前已经见过好多因为默认激活 anaconda 而导致 ncurses 和 curl 异常的群友了。

离线

#7 2022-08-14 23:25:32

junix
会员
所在地: Anhui, China
注册时间: 2018-12-06
帖子: 35

Re: 【已解决】fc-cache报错

1. 建议用 miniconda
2. conda config --set auto_activate_base false

离线

页脚