Hugo: -t THEME panics, but theme=THEME in config works

Created on 14 Jun 2018  路  13Comments  路  Source: gohugoio/hugo

Prior to hugo 0.42 I was generating a site using the cli flag -t THEME Using 0.42.+ it panics (see below), but interestingly if I add theme="THEME" to my config.toml it works.

Regards,

n

./bin/hugo version
Hugo Static Site Generator v0.42.1 darwin/amd64 BuildDate: 2018-06-13T10:16:36Z

 ./bin/hugo -t client9
panic: AllThemes not set

goroutine 1 [running]:
github.com/gohugoio/hugo/hugolib/filesystems.createThemesOverlayFs(0xc4200eaa00, 0x0, 0xc42013f0f8, 0x10103e8, 0x30, 0x19ecf20, 0x1, 0xc4201f5920)
    /go/src/github.com/gohugoio/hugo/hugolib/filesystems/basefs.go:572 +0x315
github.com/gohugoio/hugo/hugolib/filesystems.(*sourceFilesystemsBuilder).Build(0xc420065c00, 0xc4201f5920, 0xc4200240c4, 0x3b)
    /go/src/github.com/gohugoio/hugo/hugolib/filesystems/basefs.go:258 +0x2ee
github.com/gohugoio/hugo/hugolib/filesystems.NewBase(0xc4200eaa00, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc42013f390)
    /go/src/github.com/gohugoio/hugo/hugolib/filesystems/basefs.go:232 +0x7e5
github.com/gohugoio/hugo/helpers.NewPathSpecWithBaseBaseFsProvided(0xc420065240, 0x1c1b200, 0xc42019de30, 0x0, 0xc420422fe0, 0x20, 0x20)
    /go/src/github.com/gohugoio/hugo/helpers/pathspec.go:59 +0x9f
github.com/gohugoio/hugo/helpers.NewPathSpec(0xc420065240, 0x1c1b200, 0xc42019de30, 0xc420422fe0, 0x0, 0x210c880)
    /go/src/github.com/gohugoio/hugo/helpers/pathspec.go:41 +0x48
github.com/gohugoio/hugo/deps.New(0xc42042a200, 0xc420065240, 0xc42019de30, 0x1c1b320, 0xc420219860, 0x1c0a3e0, 0x0, 0xc420422fe0, 0x1c0a360, 0xc420422fc0, ...)
    /go/src/github.com/gohugoio/hugo/deps/deps.go:126 +0xb0
github.com/gohugoio/hugo/hugolib.applyDepsIfNeeded(0xc42042a200, 0xc420065240, 0xc42019de30, 0x1c1b320, 0xc420219860, 0x1c0a3e0, 0x0, 0xc420422fe0, 0x1c0a360, 0xc420422fc0, ...)
    /go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:190 +0x321
github.com/gohugoio/hugo/hugolib.newHugoSites(0xc42042a200, 0xc420065240, 0x0, 0x1c1b320, 0xc420219860, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:134 +0x24d
github.com/gohugoio/hugo/hugolib.NewHugoSites(0xc42042a200, 0xc420065240, 0x0, 0x1c1b320, 0xc420219860, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:227 +0xf5
github.com/gohugoio/hugo/commands.(*commandeer).loadConfig.func3()
    /go/src/github.com/gohugoio/hugo/commands/commandeer.go:203 +0x117
sync.(*Once).Do(0xc4200967e0, 0xc42013fa98)
    /usr/local/go/src/sync/once.go:44 +0xbe
github.com/gohugoio/hugo/commands.(*commandeer).loadConfig(0xc420096790, 0xc420090001, 0x0, 0x10)
    /go/src/github.com/gohugoio/hugo/commands/commandeer.go:188 +0x562
github.com/gohugoio/hugo/commands.newCommandeer(0x1, 0xc420330060, 0x1c06da0, 0xc4203b5740, 0xc4203b5ac0, 0x0, 0x0, 0x0, 0x1980560, 0xc42001c001, ...)
    /go/src/github.com/gohugoio/hugo/commands/commandeer.go:99 +0x116
github.com/gohugoio/hugo/commands.initializeConfig(0x1980001, 0xc420330060, 0x1c06da0, 0xc4203b5740, 0xc4203b5ac0, 0xc42007fc08, 0xc42007fbd8, 0x0)
    /go/src/github.com/gohugoio/hugo/commands/hugo.go:111 +0x76
github.com/gohugoio/hugo/commands.(*commandsBuilder).newHugoCmd.func1(0xc4203fcc80, 0xc4204931a0, 0x0, 0x2, 0x0, 0x0)
    /go/src/github.com/gohugoio/hugo/commands/commands.go:151 +0x97
github.com/gohugoio/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0xc4203fcc80, 0xc42001c0d0, 0x2, 0x2, 0xc4203fcc80, 0xc42001c0d0)
    /go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/cobra/command.go:756 +0x468
github.com/gohugoio/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4203fcc80, 0xc4203b5740, 0xc420150460, 0xc42007fee8)
    /go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/cobra/command.go:846 +0x30a
github.com/gohugoio/hugo/commands.Execute(0xc42001c0d0, 0x2, 0x2, 0xc42007ff78, 0x10038ac, 0xc420028118, 0x0)
    /go/src/github.com/gohugoio/hugo/commands/hugo.go:77 +0xbe
main.main()
    /go/src/github.com/gohugoio/hugo/main.go:27 +0x7b
Bug

Most helpful comment

You can probably work around this by HUGO_THEME=mytheme hugo (i.e. setting the theme as an OS env).

All 13 comments

You can probably work around this by HUGO_THEME=mytheme hugo (i.e. setting the theme as an OS env).

This seems related to this: https://github.com/gohugoio/hugo/issues/4649. I didn't see panic in that issue, but the part about "theme works when set in config, but doesn't work when set using -t" is the same.

I'm also getting this on my sites when upgraded to v0.42.1
The workaround of using an env var works.

From git bisect, looks like this was introduced by 80230f26. When the 'allThemes' setting is read, it will panic if the slice is empty. Only setting this if the are themes in the config file seems to fix the issue.

Hi!

I'm still getting this error with version 0.44. when I use the -t flag.
Did I miss something?

Hi Christian,

Looking at the tags, this fix isn't in 0.44, believe it should be in 0.45.

Thanks

@garrmcnu Thank you for the information! I'm looking forward to 0.45. meanwhile I'll use the config property.

So server with the -t flag does absolutely nothing under
0.45.1 now.

because it depends on whether disableLiveReload is not
false by default.

That's so miserably great. Now I can't just serve unless the above
is set to true, or omit theme altogether.

Back in 0.35 I was able to just serve regardless of the
settings on the config file. Back and forth. Back and forth.
No problem. Now it is, and I have to have disableLiveReload.

Hi,
Writing to let you know that the "-t" switch still doesn't work.
The theme set in config.toml file is overriding commandline switch.
I mean "hugo serve -t " has no effect.
Please let me know if I'm missing anything.

Hugo 0.45.1 (BuildDate: 2018-07-29T18:23:19+0200)
OS: Arch Linux

@shreyanshk

you can have instead say

 themes = ["a","b","c"]

and then call

 hugo server -t b -D

of course, replace "a", "b", and "c" with whatever you want instead

it works for me and notice the themes rather than theme on the config file

but leaving out theme in the config file just doesnt work (as you know)

notice that it must have commas separated values or else it'd throw an error (as you probably know too)

@nonumeros
It sure works but isn't command line parameter supposed to override parameter set in config.yaml file?
I mean, that would make more sense.

isn't command line parameter supposed to override parameter set in config.yaml file

@shreyanshk but that's exactly what's doing with themes = ["a","b","c"] ... invoking hugo -t b on the command line overrides a and c

Likewise, with hugo 0.46, theme or themes can both be omitted on the configuration file and command line takes precedence without panicking

Saw panic: AllThemes not set in 0.44 when building multilingual page bundle and config specified theme with an array value and not themes. Error resolved with updated config identifier.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

digitalcraftsman picture digitalcraftsman  路  3Comments

VoidingWarranties picture VoidingWarranties  路  3Comments

nikolas picture nikolas  路  3Comments

tjamet picture tjamet  路  3Comments

artelse picture artelse  路  3Comments