Error: failed to create file caches from configuration


Hi all,

What I’m doing
In a CI (Jenkins), I’m trying to launch hugo to generate HTML file which contains an API documentation. The process is the following:

Jenkins slave --> launch sbt (Scala Build Tool) in a Docker --> Launch Hugo in Docker

All volumes (project and public directories) are well mounted otherwise hugo would have tell me that project/content does not exist.

What I’m expecting ? .

Hugo generates HTML file in public which is mounted with a host directory

What actually happened

I receive this error from Hugo:
Error: failed to create file caches from configuration: this is a filesystem that does nothing and this operation is not supported

But unfortunately, I have no detail to help me fixing this error
Why Hugo said that the filesystem does nothing ?

I tried to mount an anonymous volume in docker (-v /tmp) and set cache dir (-e HUGO_CACHEDIR=/tmp) and I also tried to set cacheDir parameter when launching Hugo but nothing solved this issue.

Hugo version is 0.54.0 and Docker image is Alpine:3.8

I also tried to activated --verbose but it does not produce more log (only the one I posted in this tread).

I’m sorry but I can’t share my private repository. Creating a dummy repository will also be a very hard task but if no one has a solution, I’ll try do create one.

Here is the script which is launched from sbt:

    docker build -t hugo - <<EOF
    FROM alpine:3.8
    RUN wget 
   64bit.tar.gz && \
      tar xvzf hugo_* && \
      rm -rf hugo_* LICENSE && \
      mv /hugo /usr/local/bin
    ENTRYPOINT ["hugo"]

    USERID=$(id -u)
    GROUPID=$(id -g)
    # Assume following parameters :
    # $1 The source directory (content, css, js, ...)
    # $2 The destination directory of generated HTML files
    # The following substitutions aim to fix the Docker-next-to-Docker when 
    # mounting volume (source volume are from the HOST, not the middle container)
    echo "Generating $HUGO_DEST files from $HUGO_SOURCE files"
    docker run --rm -i \
       -u ${USERID}:${GROUPID} \
       -v ${HUGO_SOURCE}:/site:ro \
       -v ${HUGO_DEST}:/public:rw \
       -v /tmp \
       -e HUGO_CACHEDIR=/tmp \
       -w /site \
       hugo \
         --destination /public --cacheDir /tmp --verbose

Thanks for your help


Have you tried not explicitly setting the cacheDir? So just a:

hugo \
  --destination /public --verbose


Yes, I showed you all options but I tried without --cacheDir first


I didn’t see that as something you tried. Regardless, though, we can now rule it out.


If it helps, here’s a maintained docker image from one of our community members if you want to compare-n-contrast your Dockerfile


Thanks for your help.

We were able to find what was wrong. Here is the explanation :

As you can see I have mounted the source files of Hugo as read-only (-v ${HUGO_SOURCE}:/site:ro \). The error was about “files caches” that’s why I tried to set the cacheDir but there are multiple cache directories and not all are sub-directories of cacheDir. This is especially true for caches.images and caches.assets which use, by default, :resourceDir/_gen directory. As resource directory was read-only, Hugo was unable to create it !

Here is what can be improved (in my opinion):

1- When an error occurs add details instead of a general error message. For the previous error an improved error message could have been
“Error: failed to create /site/resources/_gen directory for caches.images file caches from configuration: this is a read-only filesystem”. This could help to understand quickly what’s wrong.

2- Why some file caches are not part of the cacheDir directory ? I can understand that multiple cache directories are required, but using a common parent directory will be easier to set and maintain. Also using by default a sub-directory of source files is not a good idea: it will generate new files and if you use a SCM like Git, it means that your build process will create some un-commited files and of course adding those files in .gitignore is not a good option: sources and generated files (even temporary files) must be in separated directories.

(my 2 cents)

Hope this thread can help other.
Thanks again for your time