Skip to content

[package] fontconfig/2.15.0 (also 2.17.1): Cannot load default config file #29979

@scandyna

Description

@scandyna

Description

Currently, the fontconfig recipe hardcodes sysconfdir and datadir to res/etc and res/share respectively. This means the Conan-built fontconfig cannot find the system font configuration at runtime without external workarounds.

Related issues

Workaround

A workaround is to pass a Meson machine file via tools.meson.mesontoolchain:extra_machine_files and include it in the package ID using tools.info.package_id:confs, as explained here: #5782 (comment).

Example of a Meson machine file named fontconfig_meson_project_options_ubuntu.ini:

[project options]
sysconfdir = '/etc'
datadir = '/usr/share'

Example of linux_ubuntu_gcc13.jinja profile:

[conf]
fontconfig/*:tools.meson.mesontoolchain:extra_machine_files=['{{ os.path.join(profile_dir, "fontconfig_meson_project_options_ubuntu.ini") }}']
fontconfig/*:tools.info.package_id:confs=["tools.meson.mesontoolchain:extra_machine_files"]

Notice that we have to give the full path to the Meson machine file.
Also, we have to affect the package ID.

Issue with this workaround

With this I can build my projects, depending on Qt (and Fontconfig), on the CI (using Docker images).
But, when I want to work on my PC, Conan can't find the matching packages (same profiles, same system, Ubuntu-24.04).

This is because the absolute path to the .ini file becomes part of the package ID hash. Since this path differs between machines (e.g. /root/.conan2/profiles/... in CI vs /home/user/.conan2/profiles/... locally), the computed package ID for fontconfig differs even though the actual build output is identical.

The only escape is conan install ... --build=missing, which we want to avoid while having big dependencies.

Proposed fix

Add an option to allow using the platform provided Fontconfig config/database.

I will try this on my side.
If I land on something that could work, I will submit a PR.

Package and Environment Details

  • Package Name/Version: fontconfig/2.15.0 (also 2.17.1)
  • Operating System+version: Linux Ubuntu 24.04
  • Compiler+version: GCC 13.3.0
  • Conan version: 2.26.2
  • Python version: Python 3.12.3

Conan profile

Click to expand
[settings]
arch=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux
os.distribution=ubuntu-24.04
qt/6.*:compiler.cppstd=gnu17
[options]
boost/*:header_only=True
fontconfig/*:shared=False
qt/5.*:gui=True
qt/5.*:qtserialport=True
qt/5.*:shared=True
qt/5.*:widgets=True
qt/5.*:with_glib=False
qt/5.*:with_mysql=False
qt/5.*:with_odbc=True
qt/5.*:with_pq=True
qt/5.*:with_sqlite3=True
qt/5.*:with_vulkan=False
qt/6.*:gui=True
qt/6.*:qt5compat=True
qt/6.*:qtserialport=True
qt/6.*:shared=True
qt/6.*:widgets=True
qt/6.*:with_glib=False
qt/6.*:with_mysql=False
qt/6.*:with_odbc=True
qt/6.*:with_pq=True
qt/6.*:with_sqlite3=True
qt/6.*:with_vulkan=False
[replace_requires]
libpq/*: libpq/[>=17.5 <18]
[buildenv]
CC=gcc-13
CXX=g++-13

Steps to reproduce

Build an app using Qt6 (or Qt5) and run it.
The font rendering will be ugly.
In the terminal, this will be displayed:

Fontconfig error: Cannot load default config file: No such file: (null)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions