[SOLVED] `hugo new site <name>` stopped working when upgraded to v0.17 using Ubuntu Snap

I originally installed Hugo using apt install hugo but it only installed v0.16. I was able to use hugo new site <name> using that version. Later on, I found myself needing v0.17 because of a theme. So, I uninstalled Hugo, then installed v0.17 using Ubuntu Snaps.

Now when I try hugo new site <name>, I receive the following error:

pat@ubuntu:~$ hugo new site johnsalcedonetwork.github.io
2016/11/07 19:40:12 mkdir /home/pat/johnsalcedonetwork.github.io/: permission denied
panic: mkdir /home/pat/johnsalcedonetwork.github.io/: permission denied


goroutine 1 [running]:
panic(0xb05d20, 0xc8201b92c0)
	/usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6
log.Panicln(0xc820119638, 0x1, 0x1)
	/usr/lib/go-1.6/src/log/log.go:334 +0xc1
github.com/spf13/afero.WriteReader(0x7f49be56f848, 0x11f1de8, 0xc8201ba980, 0x32, 0x7f49be56f408, 0xc8201f94a0, 0x7f49be5757c8, 0xc8201f9560)
	/build/hugo/parts/hugo/go/src/github.com/spf13/afero/util.go:49 +0x34c
github.com/spf13/hugo/helpers.WriteToDisk(0xc8201ba980, 0x32, 0x7f49be56f408, 0xc8201f94a0, 0x7f49be56f848, 0x11f1de8, 0x0, 0x0)
	/build/hugo/parts/hugo/go/src/github.com/spf13/hugo/helpers/path.go:570 +0x64
github.com/spf13/hugo/commands.createConfig(0xc8201f8930, 0x26, 0xd40218, 0x4, 0x0, 0x0)
	/build/hugo/parts/hugo/go/src/github.com/spf13/hugo/commands/new.go:334 +0x570
github.com/spf13/hugo/commands.doNewSite(0xc8201f8930, 0x26, 0x0, 0x0, 0x0)
	/build/hugo/parts/hugo/go/src/github.com/spf13/hugo/commands/new.go:151 +0xded
github.com/spf13/hugo/commands.NewSite(0x11ccc80, 0xc8201b8ea0, 0x1, 0x1, 0x0, 0x0)
	/build/hugo/parts/hugo/go/src/github.com/spf13/hugo/commands/new.go:181 +0x3dc
github.com/spf13/cobra.(*Command).execute(0x11ccc80, 0xc8201b8e10, 0x1, 0x1, 0x0, 0x0)
	/build/hugo/parts/hugo/go/src/github.com/spf13/cobra/command.go:622 +0x6bb
github.com/spf13/cobra.(*Command).ExecuteC(0x11cb960, 0x11ccc80, 0x0, 0x0)
	/build/hugo/parts/hugo/go/src/github.com/spf13/cobra/command.go:712 +0x55c
github.com/spf13/hugo/commands.Execute()
	/build/hugo/parts/hugo/go/src/github.com/spf13/hugo/commands/hugo.go:174 +0x77
main.main()
	/build/hugo/parts/hugo/go/src/github.com/spf13/hugo/main.go:26 +0x28

Here are some additional details that I think would help. Let me know if I need to provide additional information. I am a noob to both Hugo and Linux.

pat@ubuntu:~$ env | grep -i hugo
pat@ubuntu:~$ env | grep -i go
pat@ubuntu:~$ which go
/usr/bin/go
pat@ubuntu:~$ which hugo
/snap/bin/hugo
pat@ubuntu:~$ tree -a /snap/hugo
/snap/hugo
├── 22
│   ├── bin
│   │   └── hugo
│   ├── command-hugo.wrapper
│   └── meta
│       └── snap.yaml
└── current -> 22

4 directories, 3 files

How do I fix it?

Looks like a permission issue. See if you can run the mkdir command yourself as pat.

I tried chmod 777 pat, but I’m still getting the same error.

pat@ubuntu:/home$ ls -l
total 4
drwxrwxrwx 19 pat pat 4096 Nov  7 19:54 pat

mkdir works per se, however.

pat@ubuntu:~$ mkdir johnsalcedonetwork.github.io
pat@ubuntu:~$ ls
Desktop  Documents  Downloads  examples.desktop  go  johnsalcedonetwork.github.io  johnsalcedonetwork.github.io.bak  Music  Pictures  Public  snap  Templates  Videos
pat@ubuntu:~$ hugo new site johnsalcedonetwork.github.io
Error: /home/pat/johnsalcedonetwork.github.io already exists and is not empty

try removing the directory and run the command again.
rmdir johnsalcedonetwork.github.io
hugo new site johnsalcedonetwork.github.io

try in different directories like /tmp where you don’t have permission restrictions

Also, 777 is a bad permission to set . Later change your directory to 711.

Another alternative would be to try to install hugo from source since you have go installed (warning: this could be a bit advanced for a beginner)

Thanks for the attention, sairam. I’m glad to announce that for some reason, it’s working now. I simply reinstalled Hugo using the following:
snap remove hugo
snap install hugo