New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chromium in container Fontconfig error: Cannot load default config file: No such file: (null)
#176081
Comments
The problem goes away with this patch: "--no-sandbox"
"--disable-gpu"
];
+ Env = [
+ "FONTCONFIG_FILE=${pkgs.fontconfig.out}/etc/fonts/fonts.conf"
+ "FONTCONFIG_PATH=${pkgs.fontconfig.out}/etc/fonts/"
+ ];
};
};
devShells.x86_64-linux.default = pkgs.mkShell { I'm not sure if this is expected behaviour. It was surprising to me TBH. |
I would say that is expected. Fontconfig requires Though I guess it might make sense to patch fontconfig as follows to allow it working in environments where fontconfig is not installed globally: --- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,6 +80,7 @@ AM_CPPFLAGS = \
$(WARN_CFLAGS) \
-DFC_CACHEDIR='"$(FC_CACHEDIR)"' \
-DCONFIGDIR='"$(CONFIGDIR)"' \
+ -DFALLBACK_FONTCONFIG_PATH='"$(prefix)/etc/fonts"'\
-DFONTCONFIG_PATH='"$(BASECONFIGDIR)"' \
-DFC_TEMPLATEDIR='"$(TEMPLATEDIR)"'
LDADD = $(LIBINTL)
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -2439,7 +2439,7 @@ FcConfigGetPath (void)
int npath;
int i;
- npath = 2; /* default dir + null */
+ npath = 3; /* default dir + fallback dir + null */
env = (FcChar8 *) getenv ("FONTCONFIG_PATH");
if (env)
{
@@ -2491,6 +2491,14 @@ FcConfigGetPath (void)
if (!path[i])
goto bail1;
strcpy ((char *) path[i], (const char *) dir);
+
+ // Fallback for Nixpkgs.
+ dir = (FcChar8 *) FALLBACK_FONTCONFIG_PATH;
+ path[i] = malloc (strlen ((char *) dir) + 1);
+ if (!path[i])
+ goto bail1;
+ strcpy ((char *) path[i], (const char *) dir);
+
return path;
bail1: |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/imagemagicks-convert-command-fails-due-to-fontconfig-error/20518/3 |
Can we please merge this? I just spent too many hours until I figured out why my application that depends on fontconfig via chromedriver did not work. |
I'm seeing this issue in my nested VM. Not seeing this problem on an Arch guest, so unfortunately this is a big limiting factor in using nixos as a workstation guest If something in the previous comments solves the issue, can someone indiciate where I have to make that change manually by any chance? I am not familiar enough with nixos/linux perhaps to understand where to add these snippets of code. |
If your working with docker tools this should work: Or you could clone nixpkgs and apply this patch #176081 (comment) to fontconfig and then install whatever package you want to use from your clone. If not, then you should make sure that those environment variables are set correctly in the context of the binary that you are trying to use. |
Describe the bug
It seems to be a resurrection of #101211, or at least I found proper STR.
When Chromium is executed inside a container, it cannot find fontconfig and it fails.
Steps To Reproduce
Steps to reproduce the behavior:
flake.nix
:Expected behavior
Chromium shouldn't fail with the fontconfig error.
Screenshots
N/A
Additional context
I'm packaging Odoo in a container. It uses Chromium behind the scenes to run unit tests. I included all the flags it uses (resolved) to run Chromium in a container-friendly fashion.
Tests fail with
Inspector.targetCrashed
error.A similar container-based approach based on debian doesn't crash like this. I inspected the same command in both containers and found that this issue's error is the main difference.
When I run the same command outside the container, Chromium works happily. My guess is that it's getting the font config from my host OS (Fedora Silverblue 36). I'm not using NixOS FWIW.
Notify maintainers
@primeos @thefloweringash
Metadata
I gave a nix flake to get it more reproducible, so I guess this is the required metadata:
The text was updated successfully, but these errors were encountered: