Wkhtmltopdf Fontconfig error: “No writable cache directories” on ERPNext v15 (Jammy)

Hi everyone,

I’m facing a persistent PDF generation error in ERPNext / Frappe v15 when downloading print formats or sending emails with PDF attachments.


Environment

  • OS: Ubuntu 22.04 (Jammy)

  • Python: 3.12

  • Frappe: 15.56.0

  • ERPNext: 15.50.1

  • wkhtmltopdf: 0.12.6.1 (with patched Qt)

  • Installed via: wkhtmltox_0.12.6.1-2.jammy_amd64.deb

  • Binary location: /usr/local/bin/wkhtmltopdf


Error

When downloading a PDF or sending Email Queue with print attachment:

OSError: wkhtmltopdf reported an error:
Fontconfig error: No writable cache directoriesExit with code 1 due to network error: SslHandshakeFailedError

Traceback (shortened)

frappe.utils.pdf.get_pdf → pdfkit.from_string → wkhtmltopdf → Fontconfig error: No writable cache directories 

What I’ve already verified / tried

  • :white_check_mark: Correct wkhtmltopdf version (patched Qt)

  • :white_check_mark: fontconfig installed

  • :white_check_mark: /var/cache/fontconfig exists and is writable

  • :white_check_mark: Cache files present in /var/cache/fontconfig

  • :white_check_mark: Fonts installed (fonts-dejavu)

  • :white_check_mark: fc-cache -fv runs successfully

  • :white_check_mark: Permissions fixed:

  • :white_check_mark: Same error occurs when running via Frappe (print format / email queue)

Despite this, wkhtmltopdf still fails with “No writable cache directories”.


Question

Has anyone encountered this issue on Ubuntu 22.04 + Python 3.12 + Frappe v15?

  • Is there a known fontconfig path issue?

  • Does wkhtmltopdf need explicit FONTCONFIG_PATH or XDG_CACHE_HOME for Frappe?

  • Any known fixes specific to Jammy or Python 3.12?

Any guidance would be appreciated :folded_hands:

Thanks!

Hi,

it may help to say the hosting environment, how Frappe/Erpnext was installed and whether this is happening on first use or if PDF generation was working at one time.

wkhtmltppdf generally works OOB when standard installation method is used, the error suggests a permission error that may be traceable to the method used to install the apps.

This was an issue for me in docker so give it a shot if you are still stuck - no harm in trying, right?