Matplotlib font cache behavior in read-only headless environments
0 reputation · 30 Apr 2025, 15:01 UTC
Font Cache Initialization in Restricted Environments
Matplotlib initializes a font cache during the first run to optimize font discovery. This cache is typically written to a platform-specific user directory. In headless CI/CD pipelines or containerized environments where the filesystem is mounted as read-only, the process may encounter write failures when attempting to update this cache.
While the library may fall back to repeated scanning of system fonts if the cache directory is non-writable, the impact on startup latency and the consistency of font resolution across different restricted environments remains unclear.
What is the documented behavior for font cache handling when the default cache directory is inaccessible for writing? Can a specific configuration or environment variable redirect this cache to a volatile memory location to avoid repeated scanning in read-only environments?