Non-default destination Transformation failed: mkdir /var/www: read-only file system

I used hugo ( installed using snap) to generate a static site for myself on my vps running ubuntu to non-default destination /var/www which is modified to permit everyone to read, right and execute.

$ hugo version
Hugo Static Site Generator v0.63.2/extended linux/amd64 BuildDate: 2020-01-27T19          :24:21Z

$ hugo --destination=/var/www/html
Building sites … WARN 2020/02/01 10:18:23 Markup type mmark is deprecated and wi          ll be removed in a future release. See https://gohugo.io//content-management/for          mats/#list-of-content-formats
ERROR 2020/02/01 10:18:24 Transformation failed: mkdir /var/www: read-only file           system
ERROR 2020/02/01 10:18:24 Failed to publish Resource: mkdir /var/www: read-only           file system
ERROR 2020/02/01 10:18:24 Transformation failed: mkdir /var/www: read-only file           system
ERROR 2020/02/01 10:18:24 Failed to publish Resource: mkdir /var/www: read-only           file system
ERROR 2020/02/01 10:18:25 Failed to publish Resource for page "/home/catdog/hugo          _blog/content/authors/admin/_index.md": mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
ERROR 2020/02/01 10:18:25 mkdir /var/www: read-only file system
Total in 2742 ms
Error: Error copying static files: mkdir /var/www: read-only file system

I am using a vultr vps with Ubuntu 18.04.

catdog@vultr:~/hugo_blog$ uname -a
Linux vultr.guest 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
catdog@vultr:~/hugo_blog$ ll /var/www
total 12
drwxrwxrwx  3 root root 4096 Jan 30 01:56 ./
drwxr-xr-x 14 root root 4096 Jan 30 01:47 ../
drwxr-xr-x  2 root root 4096 Jan 30 01:56 html/
catdog@vultr:~/hugo_blog$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            462M     0  462M   0% /dev
tmpfs            99M  912K   98M   1% /run
/dev/vda1        25G  2.8G   21G  12% /
tmpfs           493M     0  493M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           493M     0  493M   0% /sys/fs/cgroup
/dev/loop0       90M   90M     0 100% /snap/core/8268
/dev/loop1       29M   29M     0 100% /snap/hugo/6955
tmpfs            99M     0   99M   0% /run/user/1000
catdog@vultr:~/hugo_blog$
catdog@vultr:~/hugo_blog$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=472952k,nr_inodes=118238,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=100908k,mode=755)
/dev/vda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=38,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13903)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
/var/lib/snapd/snaps/core_8268.snap on /snap/core/8268 type squashfs (ro,nodev,relatime,x-gdu.hide)
tmpfs on /run/snapd/ns type tmpfs (rw,nosuid,noexec,relatime,size=100908k,mode=755)
/var/lib/snapd/snaps/hugo_6955.snap on /snap/hugo/6955 type squashfs (ro,nodev,relatime,x-gdu.hide)
nsfs on /run/snapd/ns/hugo.mnt type nsfs (rw)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=100904k,mode=700,uid=1000,gid=1000)
catdog@vultr:~/hugo_blog$

It works well with other destination dir:

catdog@vultr:~/hugo_blog$ hugo --destination=/tmp/html
Building sites … WARN 2020/02/01 10:28:01 Markup type mmark is deprecated and will be removed in a future release. See https://gohugo.io//content-management/formats/#list-of-content-formats

                   | EN
-------------------+------
  Pages            | 204
  Paginator pages  |   8
  Non-page files   |   8
  Static files     |  57
  Processed images |   1
  Aliases          |  71
  Sitemaps         |   1
  Cleaned          |   0

Total in 2553 ms

I can work in /var/www normally in bash:

catdog@vultr:/var/www$ ll
total 12
drwxrwxrwx  3 root root 4096 Jan 30 01:56 ./
drwxr-xr-x 14 root root 4096 Jan 30 01:47 ../
drwxr-xr-x  2 root root 4096 Jan 30 01:56 html/
catdog@vultr:/var/www$ touch a.txt
catdog@vultr:/var/www$ mkdir bad
catdog@vultr:/var/www$ ll
total 16
drwxrwxrwx  4 root   root   4096 Feb  1 10:29 ./
drwxr-xr-x 14 root   root   4096 Jan 30 01:47 ../
-rw-rw-r--  1 catdog catdog    0 Feb  1 10:29 a.txt
drwxrwxr-x  2 catdog catdog 4096 Feb  1 10:29 bad/
drwxr-xr-x  2 root   root   4096 Jan 30 01:56 html/
catdog@vultr:/var/www$

I created an issue at Transformation failed: mkdir /var/www: read-only file system](https://github.com/gohugoio/hugo/issues/6843) , but it was closed by creator of hugo and he suggested me to repost it here.

I ran into the same problem. Had to switch from Ubuntu 22.04 to the Snap packages because of the outdated package sources. Since then I get the following error message:

‘’‘Error: error building site: process: readAndProcessContent: mkdir /var/www: read-only file system’‘’

It may be overly optimistic after three years to ask if there is a solution, but I thought I’d give it a try.

I already have a workaround by building a script that builds the site and then copies everything to /var/www/. But maybe there is a better solution.

Translated with DeepL Translate: The world's most accurate translator (free version)

https://gohugo.io/installation/linux/#snap

The Hugo snap package is strictly confined. Strictly confined snaps run in complete isolation, up to a minimal access level that’s deemed always safe. The sites you create and build must be located within your home directory, or on removable media.

Alternatives: