Where does Hugo put sites with absolute path?

I am running hugo 0.26 on Ubuntu 16.04 installed with snap. Here is more information about my system/version:

$$ cat /proc/version
Linux version 4.10.0-32-generic (buildd@lcy01-01) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #36~16.04.1-Ubuntu SMP Wed Aug 9 09:19:02 UTC 2017

$$ hugo version
Hugo Static Site Generator v0.26 linux/amd64 BuildDate: 2017-08-07T08:54:34+01:00

$$ which hugo
/snap/bin/hugo

I am confused by the following commands:

$$ hugo new site /tmp/example
Congratulations! Your new Hugo site is created in /tmp/example.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".


$$ ls /tmp/example
ls: cannot access '/tmp/example': No such file or directory

$$ hugo new site /tmp/example
Error: /tmp/example already exists and is not empty

Where does Hugo put new sites defined by absolute path?

I just tried that on Fedora 26, and I have a site in /tmp/example. Maybe snap does something with containers that could mess things up… have you tried creating a site somewhere else (maybe your home directory)?

Creating a site in the home directory works, but not anywhere else.
In particular, creating a site on a different partition yields a permission error (even though I have writing rights):

$$ hugo new site /media/user/partition/example
Error: Failed to create dir: mkdir /media/user/partition/example: permission denied

Based on that error message, my guess would be something to do with the snap package or AppArmor.

If you create a site in the home directory then move it somewhere else (e.g., /tmp/example) then run hugo server in that directory, what happens?

IIRC AppArmor logs to /var/log/kern.log; that could be a good place to start looking for an explanation.

1 Like

I think you are spot on, but I don’t know what to do about the AppArmor, could you please help me?

Creating in home, then moving, then running hugo server gives:

Error: Unable to locate Config file. Perhaps you need to create a new site.
       Run `hugo help new` for details. (Config File "config" Not Found in "[/var/lib/snapd/void]")

Even though I am in the site folder and can clearly see the configuration file.

Running a tail on /var/log/kern.log gives:

[45885.985012] audit: type=1400 audit(1503702901.920:77): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.hugo.hugo" pid=11500 comm="apparmor_parser"
[45886.116854] audit: type=1400 audit(1503702902.052:78): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/snap/core/2462/usr/lib/snapd/snap-confine" pid=11507 comm="apparmor_parser"
[45886.132072] audit: type=1400 audit(1503702902.068:79): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/snap/core/2462/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=11507 comm="apparmor_parser"
[45886.135664] audit: type=1400 audit(1503702902.068:80): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.core.hook.configure" pid=11509 comm="apparmor_parser"
[45899.025278] audit: type=1400 audit(1503702914.964:81): apparmor="DENIED" operation="capable" profile="/snap/core/2462/usr/lib/snapd/snap-confine" pid=11713 comm="snap-confine" capability=4  capname="fsetid"

Sorry, haven’t really used Ubuntu since about 2005. I could probably help with SELinux, but not AppArmor.

You might want to try Ubuntu forums, Ask Ubuntu, or an IRC channel.

Thanks a lot for your help @jetwash, I have reported the issue directly on GitHub, let’s see what happens there!

Sorry for my late reply as I had been away (again), but this is due to Snap’s security model.

See https://gohugo.io/getting-started/installing/#snap-package