Skip to content
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

Weasyprint.exe : Fontconfig error: Cannot load default config file: No such file: (null) #2138

Closed
aditya119 opened this issue Apr 27, 2024 · 8 comments

Comments

@aditya119
Copy link

Executing the weasyprint.exe works on some machines but fails on others.
Please let me know if there are some prerequisites to run the exe properly, I think the GTK and python installation is needed only for using it as a library.
I have seen other issues but they focus on running weasyprint python library on Windows, whereas I'm just trying to run the exe.

It is working fine on my development system, but fails with above error when deploying to server.

I have added various stack traces that I could extract:

WeasyPrint exited with code -1073741819.
Error: Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: "memory", line 2: SHGetFolderPathA failed
Fontconfig error: "memory", line 3: SHGetFolderPathA failed
Fontconfig error: No writable cache directories
Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: "memory", line 2: SHGetFolderPathA failed
Fontconfig error: "memory", line 3: SHGetFolderPathA failed
Fontconfig error: No writable cache directories
>weasyprint.exe --info abc.html abc.pdf
Fontconfig error: Cannot load default config file: No such file: (null)
System: Windows
Machine: AMD64
Version: 10.0.17763
Release: 2019Server

WeasyPrint version: 61.2
Python version: 3.12.2
Pydyf version: 0.9.0
Pango version: 15014
>weasyprint --debug abc.html abc.pdf
Fontconfig error: Cannot load default config file: No such file: (null)
INFO: Step 1 - Fetching and parsing HTML - abc.html
Fontconfig error: Cannot load default config file: No such file: (null)
INFO: Step 3 - Applying CSS
INFO: Step 4 - Creating formatting structure
INFO: Step 5 - Creating layout - Page 1

Thanks in advance.

@liZe
Copy link
Member

liZe commented Apr 28, 2024

Hi!

Please let me know if there are some prerequisites to run the exe properly, I think the GTK and python installation is needed only for using it as a library.

No, the exe file includes everything.

I suspect that WeasyPrint can’t reach the default Windows folders that contain fonts, for your system and for your user.

@aditya119
Copy link
Author

Thanks.
Can you please share if there is a way to find out what files/paths weasyprint is looking for?
That would help me figure out a fix.

@liZe
Copy link
Member

liZe commented Apr 28, 2024

Can you please share if there is a way to find out what files/paths weasyprint is looking for?

Disclaimer: I don’t use Windows at all.

Fontconfig’s default config searches fonts in WINDOWSUSERFONTDIR and WINDOWSFONTDIR (at least), that seem to be constant values only used in Fontconfig. Here’s the code:

https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/src/fcxml.c

So I suspect that the unavailable folder is CSIDL_LOCAL_APPDATA, which according to this documentation should be something like C:\Documents and Settings\<username>\Local Settings\Application Data.

@aditya119
Copy link
Author

aditya119 commented Apr 30, 2024

Thanks for your response.
I have looked at the folders in both server and local system - the structure, files and env variables are same.
I'm not able to find the difference.
Thanks for providing the link to source code, I'll check if I can debug and figure out the root cause.

@liZe
Copy link
Member

liZe commented Apr 30, 2024

On the server, do you launch your script with a user that has a home directory? Sometimes, on servers, scripts are launched by specific users with less rights than "normal" users.

@aditya119
Copy link
Author

Yes, the user on server is less privileged and not a 'normal' user, but I tested by running WeasyPrint.exe manually from Admin user as well and got the same error.

@aditya119
Copy link
Author

aditya119 commented May 10, 2024

Not sure about the root cause, but adding the weasyprint.exe file path to PATH environment variable seems to fix the problem on server.

@liZe
Copy link
Member

liZe commented May 10, 2024

Not sure about the root cause, but adding the weasyprint.exe file path to PATH environment variable seems to fix the problem on server.

OK, that’s strange. Let’s close the issue for now, and reopen it if the problem comes back.

@liZe liZe closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants