asciidoctor / docker-asciidoctor

:ship: A Docker image for using the Asciidoctor toolchain to process AsciiDoc content
https://hub.docker.com/r/asciidoctor/docker-asciidoctor/
Other
324 stars 149 forks source link

Fontconfig error: No writable cache directories #470

Open sdavids opened 2 months ago

sdavids commented 2 months ago
$ docker run --user "$(id -u):$(id -g)" --rm asciidoctor/docker-asciidoctor:1.76.0 fc-cache
Fontconfig error: No writable cache directories

This surfaces when you use asciidoctor-diagram with PlantUML:


$ mkdir -p /tmp/test && cd "$_"
$ cat << 'EOF' >test.adoc
[plantuml]
----
@startuml

label Test

@enduml
----
EOF
$ docker run \
  --rm \
  -u "$(id -u):$(id -g)" \
  -v '/tmp/test:/documents' \
  asciidoctor/docker-asciidoctor:1.76.0 \
  sh -c 'asciidoctor-pdf -r asciidoctor-diagram test.adoc'
Fontconfig error: No writable cache directories
...

$ docker run \
  --rm \
  -u "$(id -u):$(id -g)" \
  -v '/tmp/test:/documents' \
  asciidoctor/docker-asciidoctor:1.76.0 \
  sh -c 'asciidoctor-pdf -r asciidoctor-diagram test.adoc'

$ rm diag-plantuml-md5-*.png
$ docker run \
  --rm \
  -u "$(id -u):$(id -g)" \
  -v '/tmp/test:/documents' \
  asciidoctor/docker-asciidoctor:1.76.0 \
  sh -c 'asciidoctor-pdf -r asciidoctor-diagram test.adoc'
Fontconfig error: No writable cache directories
...
sdavids commented 2 months ago

https://fontconfig.pages.freedesktop.org/fontconfig/fontconfig-user.html#AEN73

$ docker run --user "$(id -u):$(id -g)" --rm -e XDG_CACHE_HOME=/tmp asciidoctor/docker-asciidoctor:1.76.0 sh -c 'fc-cache && ls /tmp/fontconfig'
12b26b760a24f8b4feb03ad48a333a72-le64.cache-9
3830d5c3ddfd5cd38a049b759396e72e-le64.cache-9
51d7d9064f616a814da14ac1dd7116cb-le64.cache-9
5ca8086aeacc9c68e81a71e7ef846b3b-le64.cache-9
6ba42ae0000f58711b5caaf10d690066-le64.cache-9
923e285e415b1073c8df160bee08820f-le64.cache-9
CACHEDIR.TAG
a1c95d6dfc9a7b34f44445cf81166004-le64.cache-9
b67b32625a2bb51b023d3814a918f351-le64.cache-9
c470550e31544075faff60bdbbb5d457-le64.cache-9
$ docker run \
  --rm \
  -u "$(id -u):$(id -g)" \
  -v '/tmp/test:/documents' \
  -e XDG_CACHE_HOME=/tmp \
  asciidoctor/docker-asciidoctor:1.76.0 \
  sh -c 'asciidoctor-pdf -r asciidoctor-diagram test.adoc'

You might want to add ENV XDG_CACHE_HOME=<some world writable location other than /tmp> to your Dockerfile.

so that --user "$(id -u):$(id -g)" can write to it.