New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slash issue in themesDir and similar settings #3568

Open
XhmikosR opened this Issue Jun 7, 2017 · 18 comments

Comments

Projects
None yet
4 participants
@XhmikosR

XhmikosR commented Jun 7, 2017

C:\Users\xmr\Desktop\foo-bar>hugo version
Hugo Static Site Generator v0.21 windows/amd64 BuildDate: 2017-06-05T19:44:37+03:00

C:\Users\xmr\Desktop\foobar>hugo server --watch --verbose
INFO 2017/06/07 21:53:42 Using config file:
INFO 2017/06/07 21:53:42 C:\Users\xmr\Desktop\foobar\src\static\ is the only static directory available to sync from
INFO 2017/06/07 21:53:42 syncing static files to C:\Users\xmr\Desktop\foobar\
WARN 2017/06/07 21:53:42 No translation bundle found for default language "en"
WARN 2017/06/07 21:53:42 Translation func for language en not found, use default.
WARN 2017/06/07 21:53:42 i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/spf13/hugo/tpl/tplimpl.(*templateHandler).loadTemplates.func1(0xc0421aeb90, 0x4a, 0xf33f40, 0xc0421bd740, 0x0, 0x0, 0xc04244e580, 0xc04244e560)
        /Users/bep/go/src/github.com/spf13/hugo/tpl/tplimpl/template.go:448 +0xd35
github.com/spf13/hugo/vendor/github.com/spf13/afero.walk(0xf359a0, 0xfa7d40, 0xc0421aeb90, 0x4a, 0xf33f40, 0xc0421bd740, 0xc042450780, 0x0, 0x0)
        /Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/afero/path.go:44 +0x88
github.com/spf13/hugo/vendor/github.com/spf13/afero.walk(0xf359a0, 0xfa7d40, 0xc042452040, 0x34, 0xf33f40, 0xc0421bd5c0, 0xc042450780, 0x0, 0x34)
        /Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/afero/path.go:69 +0x462
github.com/spf13/hugo/vendor/github.com/spf13/afero.Walk(0xf359a0, 0xfa7d40, 0xc042452040, 0x34, 0xc042450780, 0x6, 0x64)
        /Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/afero/path.go:107 +0x10a
github.com/spf13/hugo/helpers.SymbolicWalk(0xf359a0, 0xfa7d40, 0xc042450750, 0x2b, 0xc042450780, 0x2, 0x2b)
        /Users/bep/go/src/github.com/spf13/hugo/helpers/path.go:507 +0x2f6
github.com/spf13/hugo/tpl/tplimpl.(*templateHandler).loadTemplates(0xc042352800, 0xc042450750, 0x2b, 0x0, 0x0)
        /Users/bep/go/src/github.com/spf13/hugo/tpl/tplimpl/template.go:480 +0x207
github.com/spf13/hugo/tpl/tplimpl.(*templateHandler).LoadTemplates(0xc042352800, 0xc042450750, 0x2b, 0x0, 0x0)
        /Users/bep/go/src/github.com/spf13/hugo/tpl/tplimpl/template.go:290 +0x5a
github.com/spf13/hugo/hugolib.(*Site).withSiteTemplates.func1(0xf344e0, 0xc042352800, 0x0, 0xfa8070)
        /Users/bep/go/src/github.com/spf13/hugo/hugolib/hugo_sites.go:136 +0x87
github.com/spf13/hugo/tpl/tplimpl.(*TemplateProvider).Update(0x0, 0xc042160750, 0x0, 0x0)
        /Users/bep/go/src/github.com/spf13/hugo/tpl/tplimpl/templateProvider.go:35 +0x4cb
github.com/spf13/hugo/deps.(*Deps).LoadResources(0xc042160750, 0xc04200d580, 0xc0421bc240)
        /Users/bep/go/src/github.com/spf13/hugo/deps/deps.go:68 +0x79
github.com/spf13/hugo/hugolib.applyDepsIfNeeded(0xc0420560e0, 0xc04200d580, 0xc0421bc240, 0xf346c0, 0xc042133680, 0xf2d260, 0x0, 0xc0421b06f0, 0xf2d1e0, 0xc0421d0740, ...)
        /Users/bep/go/src/github.com/spf13/hugo/hugolib/hugo_sites.go:107 +0x308
github.com/spf13/hugo/hugolib.newHugoSites(0xc0420560e0, 0xc04200d580, 0x0, 0xf346c0, 0xc042133680, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/bep/go/src/github.com/spf13/hugo/hugolib/hugo_sites.go:66 +0x2ed
github.com/spf13/hugo/hugolib.NewHugoSites(0xc0420560e0, 0xc04200d580, 0x0, 0xf346c0, 0xc042133680, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/bep/go/src/github.com/spf13/hugo/hugolib/hugo_sites.go:131 +0xd5
github.com/spf13/hugo/commands.(*commandeer).initSites(0xc0421d18c0, 0x17, 0x72)
        /Users/bep/go/src/github.com/spf13/hugo/commands/hugo.go:741 +0x5d
github.com/spf13/hugo/commands.(*commandeer).buildSites(0xc0421d18c0, 0x1, 0x0, 0xc042176a20)
        /Users/bep/go/src/github.com/spf13/hugo/commands/hugo.go:752 +0x39
github.com/spf13/hugo/commands.(*commandeer).build(0xc0421d18c0, 0xc04202dade, 0x1, 0x1, 0xc0421d4610, 0x16)
        /Users/bep/go/src/github.com/spf13/hugo/commands/hugo.go:529 +0xae
github.com/spf13/hugo/commands.server(0xf83ac0, 0xc042002ca0, 0x0, 0x2, 0x0, 0x0)
        /Users/bep/go/src/github.com/spf13/hugo/commands/server.go:162 +0x840
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0xf83ac0, 0xc042002c60, 0x2, 0x2, 0xf83ac0, 0xc042002c60)
        /Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:620 +0x3ff
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xf82200, 0xbfe518, 0x4043d3, 0xc042014178)
        /Users/bep/go/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:699 +0x340
github.com/spf13/hugo/commands.Execute()
        /Users/bep/go/src/github.com/spf13/hugo/commands/hugo.go:172 +0x67
main.main()
        /Users/bep/go/src/github.com/spf13/hugo/main.go:27 +0x3d
archetypedir:       "src/archetypes"
contentdir:         "src/content"
dataDir:            "src/data"
layoutdir:          "src/layouts"
staticdir:          "src/static"
themesdir:          "src/themes"

The culprit seems to be the src directory; if I move the folders one dir up, to the same dir as config.yml then everything works.

It's like Hugo can't figure out the config file on Windows. Because I still don't get the config path after Using config file: even when things work.

OS: Windows 7 64-bit.

@dominique-mueller

This comment has been minimized.

Show comment
Hide comment
@dominique-mueller

dominique-mueller Jun 8, 2017

Having the exact same issue here! I'm using the same version of hugo with the identical configuration (yet as JSON), but on Windows 10 64 bit.

However, I've found a fix: Changing the forward slashes to backward flashes seems to fix the issue. So, for example, changing src/content to src\\content (double slash because of escaping in JSON) makes Hugo build the site properly.

Still - is this intended? Seems to me it's a Windows-only issue related of not normalizing paths correctly?

dominique-mueller commented Jun 8, 2017

Having the exact same issue here! I'm using the same version of hugo with the identical configuration (yet as JSON), but on Windows 10 64 bit.

However, I've found a fix: Changing the forward slashes to backward flashes seems to fix the issue. So, for example, changing src/content to src\\content (double slash because of escaping in JSON) makes Hugo build the site properly.

Still - is this intended? Seems to me it's a Windows-only issue related of not normalizing paths correctly?

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 8, 2017

Member

Still - is this intended?

No, it is a bug and we will fix it. But remember that Hugo is all about paths and URLs and we support Windows + a bunch of Unix variants, so this is an easy mistake to make.

But a change to src\\content should be future safe and should in my head also work fine on *nix.

Member

bep commented Jun 8, 2017

Still - is this intended?

No, it is a bug and we will fix it. But remember that Hugo is all about paths and URLs and we support Windows + a bunch of Unix variants, so this is an easy mistake to make.

But a change to src\\content should be future safe and should in my head also work fine on *nix.

@bep bep changed the title from panic: runtime error: slice bounds out of range to Slash issue in themesDir and similar settings Jun 8, 2017

@bep bep added the Bug label Jun 8, 2017

@bep bep added this to the v0.23 milestone Jun 8, 2017

@XhmikosR

This comment has been minimized.

Show comment
Hide comment
@XhmikosR

XhmikosR Jun 8, 2017

No worries, it's easy to miss something.

Are there any real tests? If so you could use AppVeyor for Windows testing.

EDIT: I see you already use AppVeyor so I guess it's something the tests don't cover :)

XhmikosR commented Jun 8, 2017

No worries, it's easy to miss something.

Are there any real tests? If so you could use AppVeyor for Windows testing.

EDIT: I see you already use AppVeyor so I guess it's something the tests don't cover :)

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 8, 2017

Member

EDIT: I see you already use AppVeyor so I guess it's something the tests don't cover :)

Believe me, without AppVeyor we would be totally lost on the Windows side. But I have not thought about this issue before (i.e. putting everything below src etc.), but a fix for this issue will include such a test.

Member

bep commented Jun 8, 2017

EDIT: I see you already use AppVeyor so I guess it's something the tests don't cover :)

Believe me, without AppVeyor we would be totally lost on the Windows side. But I have not thought about this issue before (i.e. putting everything below src etc.), but a fix for this issue will include such a test.

@XhmikosR

This comment has been minimized.

Show comment
Hide comment
@XhmikosR

XhmikosR Jun 8, 2017

I always try to organize my folders and files in a strict way hence why I choose a subdirectory. It was the first thing I hit when I tried Hugo and being that it's the first time I play with Hugo I though it was my fault somewhere :/

XhmikosR commented Jun 8, 2017

I always try to organize my folders and files in a strict way hence why I choose a subdirectory. It was the first thing I hit when I tried Hugo and being that it's the first time I play with Hugo I though it was my fault somewhere :/

@dominique-mueller

This comment has been minimized.

Show comment
Hide comment
@dominique-mueller

dominique-mueller Jun 8, 2017

Same here, I first thought I've made a mistake. But when I checked out some other existing Hugo site from GitHub I've ran into the same issue. Gladfully, I've then found this issue here.

dominique-mueller commented Jun 8, 2017

Same here, I first thought I've made a mistake. But when I checked out some other existing Hugo site from GitHub I've ran into the same issue. Gladfully, I've then found this issue here.

@bep bep added Enhancement and removed Bug labels Jun 8, 2017

@bep bep modified the milestones: v0.23, v0.24 Jun 16, 2017

@bep bep modified the milestones: v0.24, v0.25 Jun 20, 2017

@bep bep modified the milestones: v0.25, v0.26 Jul 5, 2017

@XhmikosR

This comment has been minimized.

Show comment
Hide comment
@XhmikosR

XhmikosR Jul 8, 2017

@bep: this shouldn't be tagged as an enhancement. It's a regression because it worked up until some point.

XhmikosR commented Jul 8, 2017

@bep: this shouldn't be tagged as an enhancement. It's a regression because it worked up until some point.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 8, 2017

Member

@XhmikosR no, this has always behaved like this, and this works fine if you use "\\" slashes.

Member

bep commented Jul 8, 2017

@XhmikosR no, this has always behaved like this, and this works fine if you use "\\" slashes.

@bep bep added Bug and removed Enhancement labels Jul 8, 2017

@XhmikosR

This comment has been minimized.

Show comment
Hide comment
@XhmikosR

XhmikosR Jul 8, 2017

XhmikosR commented Jul 8, 2017

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 8, 2017

Member

Bit then it will fail on non Windows won't it?

No, I'm pretty sure that will still work on *nix, but as I said, we will fix this, eventually.

Member

bep commented Jul 8, 2017

Bit then it will fail on non Windows won't it?

No, I'm pretty sure that will still work on *nix, but as I said, we will fix this, eventually.

@mumblecrunch

This comment has been minimized.

Show comment
Hide comment
@mumblecrunch

mumblecrunch Jul 13, 2017

This error can be recreated on Linux (OpenSuSE 42.1) and MacOS Sierra (10.12.5) with hugo 0.25.1.

Three conditions must be met:

  • the --layoutDir argument is given on the command line
  • the argument to the --layoutDir argument contains a non-terminating slash
  • the directory pointed to by the --layoutDir is not empty

So if you fire up a new hugo directory, download a theme, config and run hugo, you won't have a problem. But as soon as you put something (even an empty file) in the layouts directory, it fails:

MacBook-Pro:/tmp/hugotest> uname -a
Darwin MacBook-Pro-3 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

MacBook-Pro:/tmp/hugotest> hugo version
Hugo Static Site Generator v0.25.1 darwin/amd64 BuildDate: 2017-07-10T03:57:59-03:00

MacBook-Pro:/tmp/hugotest> ls
archetypes      config.toml     content         data            layouts         public          static          themes

MacBook-Pro:/tmp/hugotest> ls layouts/
MacBook-Pro:/tmp/hugotest>

MacBook-Pro:/tmp/hugotest> hugo --quiet --themesDir ./themes/
MacBook-Pro:/tmp/hugotest>

MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --layoutDir ./layouts --quiet
MacBook-Pro:/tmp/hugotest>

MacBook-Pro:/tmp/hugotest> touch layouts/index.html
MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --layoutDir ./layouts --quiet                          
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/gohugoio/hugo/tpl/tplimpl.(*templateHandler).loadTemplates.func1(0xc42037e7b0, 0x2e, 0x1b5f600, 0xc4202e9c70, 0x0, 0x
0, 0xc420341370, 0x10879bb)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/template.go:448 +0xd2e
github.com/gohugoio/hugo/vendor/github.com/spf13/afero.walk(0x1b61260, 0x1bcf900, 0xc42037e7b0, 0x2e, 0x1b5f600, 0xc4202e9c70, 0
xc42037e690, 0x0, 0x2e)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/afero/path.go:44 +0x81
github.com/gohugoio/hugo/vendor/github.com/spf13/afero.Walk(0x1b61260, 0x1bcf900, 0xc42037e7b0, 0x2e, 0xc42037e690, 0x1, 0x1)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/afero/path.go:107 +0x103
github.com/gohugoio/hugo/helpers.SymbolicWalk(0x1b61260, 0x1bcf900, 0xc42037e660, 0x23, 0xc42037e690, 0x2, 0x23)
        /Users/bep/go/src/github.com/gohugoio/hugo/helpers/path.go:513 +0x2ef
github.com/gohugoio/hugo/tpl/tplimpl.(*templateHandler).loadTemplates(0xc4202ea980, 0xc42037e660, 0x23, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/template.go:480 +0x200
github.com/gohugoio/hugo/tpl/tplimpl.(*templateHandler).LoadTemplates(0xc4202ea980, 0xc42037e660, 0x23, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/template.go:290 +0x53
github.com/gohugoio/hugo/hugolib.(*Site).withSiteTemplates.func1(0x1b5fba0, 0xc4202ea980, 0x0, 0x1bcfc18)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:159 +0x80
github.com/gohugoio/hugo/tpl/tplimpl.(*TemplateProvider).Update(0x0, 0xc42027ad80, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/templateProvider.go:35 +0x4c4
github.com/gohugoio/hugo/deps.(*Deps).LoadResources(0xc42027ad80, 0xc420182300, 0xc4202e6d80)
        /Users/bep/go/src/github.com/gohugoio/hugo/deps/deps.go:68 +0x72
github.com/gohugoio/hugo/hugolib.applyDepsIfNeeded(0xc420070100, 0xc420182300, 0xc4202e6d80, 0x1b5fd80, 0xc420165770, 0x1b587e0,
 0x0, 0xc4202cf200, 0x1b58760, 0xc4202ec260, ...)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:130 +0x301
github.com/gohugoio/hugo/hugolib.newHugoSites(0xc420070100, 0xc420182300, 0x0, 0x1b5fd80, 0xc420165770, 0x0, 0x0, 0x0, 0x0, 0x0,
 ...)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:89 +0x2e6
github.com/gohugoio/hugo/hugolib.NewHugoSites(0xc420070100, 0xc420182300, 0x0, 0x1b5fd80, 0xc420165770, 0x0, 0x0, 0x0, 0x0, 0x0,
 ...)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:154 +0xce
github.com/gohugoio/hugo/commands.(*commandeer).initSites(0xc420254480, 0x17, 0xc420248300)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:733 +0x56
github.com/gohugoio/hugo/commands.(*commandeer).buildSites(0xc420254480, 0x0, 0x0, 0x10)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:744 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).build(0xc420254480, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:521 +0xa7
github.com/gohugoio/hugo/commands.glob..func8(0x1ba9aa0, 0xc420018af0, 0x0, 0x5, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:133 +0xb2
github.com/gohugoio/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0x1ba9aa0, 0xc4200100d0, 0x5, 0x5, 0x1ba9aa0, 0xc42001
00d0)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/cobra/command.go:647 +0x3f8
github.com/gohugoio/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1ba9aa0, 0x1811fa8, 0x100610c, 0xc4200100b8)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/cobra/command.go:726 +0x339
github.com/gohugoio/hugo/commands.Execute()
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:172 +0x60
main.main()
        /Users/bep/go/src/github.com/gohugoio/hugo/main.go:27 +0x36

Interestingly, if you use a trailing slash on the layouts directory, you see a fencepost error in the path:

MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --layoutDir layouts/ --quiet
ERROR 2017/07/13 00:10:28 Failed to resolve template in path "/tmp/hugotest/layouts/index.html": open /tmp/hugotest/layouts/ndex.html: no such file or directory

Also interesting, if you don't specify a layouts directory, everything works fine:

MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --quiet
MacBook-Pro:/tmp/hugotest>

That a --layoutDir argument triggers it makes sense given that the stack trace points at line 448 of hugo/tpl/tplimpl/template.go which is pretty explicitly operating on the path of the layout directory:

template.go lines 446 - 448:

li := strings.LastIndex(path, layoutDir) + len(layoutDir) + 1
relPath := path[li:]
templateDir := path[:li-len(layoutDir)-1]

mumblecrunch commented Jul 13, 2017

This error can be recreated on Linux (OpenSuSE 42.1) and MacOS Sierra (10.12.5) with hugo 0.25.1.

Three conditions must be met:

  • the --layoutDir argument is given on the command line
  • the argument to the --layoutDir argument contains a non-terminating slash
  • the directory pointed to by the --layoutDir is not empty

So if you fire up a new hugo directory, download a theme, config and run hugo, you won't have a problem. But as soon as you put something (even an empty file) in the layouts directory, it fails:

MacBook-Pro:/tmp/hugotest> uname -a
Darwin MacBook-Pro-3 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

MacBook-Pro:/tmp/hugotest> hugo version
Hugo Static Site Generator v0.25.1 darwin/amd64 BuildDate: 2017-07-10T03:57:59-03:00

MacBook-Pro:/tmp/hugotest> ls
archetypes      config.toml     content         data            layouts         public          static          themes

MacBook-Pro:/tmp/hugotest> ls layouts/
MacBook-Pro:/tmp/hugotest>

MacBook-Pro:/tmp/hugotest> hugo --quiet --themesDir ./themes/
MacBook-Pro:/tmp/hugotest>

MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --layoutDir ./layouts --quiet
MacBook-Pro:/tmp/hugotest>

MacBook-Pro:/tmp/hugotest> touch layouts/index.html
MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --layoutDir ./layouts --quiet                          
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/gohugoio/hugo/tpl/tplimpl.(*templateHandler).loadTemplates.func1(0xc42037e7b0, 0x2e, 0x1b5f600, 0xc4202e9c70, 0x0, 0x
0, 0xc420341370, 0x10879bb)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/template.go:448 +0xd2e
github.com/gohugoio/hugo/vendor/github.com/spf13/afero.walk(0x1b61260, 0x1bcf900, 0xc42037e7b0, 0x2e, 0x1b5f600, 0xc4202e9c70, 0
xc42037e690, 0x0, 0x2e)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/afero/path.go:44 +0x81
github.com/gohugoio/hugo/vendor/github.com/spf13/afero.Walk(0x1b61260, 0x1bcf900, 0xc42037e7b0, 0x2e, 0xc42037e690, 0x1, 0x1)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/afero/path.go:107 +0x103
github.com/gohugoio/hugo/helpers.SymbolicWalk(0x1b61260, 0x1bcf900, 0xc42037e660, 0x23, 0xc42037e690, 0x2, 0x23)
        /Users/bep/go/src/github.com/gohugoio/hugo/helpers/path.go:513 +0x2ef
github.com/gohugoio/hugo/tpl/tplimpl.(*templateHandler).loadTemplates(0xc4202ea980, 0xc42037e660, 0x23, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/template.go:480 +0x200
github.com/gohugoio/hugo/tpl/tplimpl.(*templateHandler).LoadTemplates(0xc4202ea980, 0xc42037e660, 0x23, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/template.go:290 +0x53
github.com/gohugoio/hugo/hugolib.(*Site).withSiteTemplates.func1(0x1b5fba0, 0xc4202ea980, 0x0, 0x1bcfc18)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:159 +0x80
github.com/gohugoio/hugo/tpl/tplimpl.(*TemplateProvider).Update(0x0, 0xc42027ad80, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/tpl/tplimpl/templateProvider.go:35 +0x4c4
github.com/gohugoio/hugo/deps.(*Deps).LoadResources(0xc42027ad80, 0xc420182300, 0xc4202e6d80)
        /Users/bep/go/src/github.com/gohugoio/hugo/deps/deps.go:68 +0x72
github.com/gohugoio/hugo/hugolib.applyDepsIfNeeded(0xc420070100, 0xc420182300, 0xc4202e6d80, 0x1b5fd80, 0xc420165770, 0x1b587e0,
 0x0, 0xc4202cf200, 0x1b58760, 0xc4202ec260, ...)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:130 +0x301
github.com/gohugoio/hugo/hugolib.newHugoSites(0xc420070100, 0xc420182300, 0x0, 0x1b5fd80, 0xc420165770, 0x0, 0x0, 0x0, 0x0, 0x0,
 ...)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:89 +0x2e6
github.com/gohugoio/hugo/hugolib.NewHugoSites(0xc420070100, 0xc420182300, 0x0, 0x1b5fd80, 0xc420165770, 0x0, 0x0, 0x0, 0x0, 0x0,
 ...)
        /Users/bep/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:154 +0xce
github.com/gohugoio/hugo/commands.(*commandeer).initSites(0xc420254480, 0x17, 0xc420248300)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:733 +0x56
github.com/gohugoio/hugo/commands.(*commandeer).buildSites(0xc420254480, 0x0, 0x0, 0x10)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:744 +0x32
github.com/gohugoio/hugo/commands.(*commandeer).build(0xc420254480, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:521 +0xa7
github.com/gohugoio/hugo/commands.glob..func8(0x1ba9aa0, 0xc420018af0, 0x0, 0x5, 0x0, 0x0)
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:133 +0xb2
github.com/gohugoio/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0x1ba9aa0, 0xc4200100d0, 0x5, 0x5, 0x1ba9aa0, 0xc42001
00d0)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/cobra/command.go:647 +0x3f8
github.com/gohugoio/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1ba9aa0, 0x1811fa8, 0x100610c, 0xc4200100b8)
        /Users/bep/go/src/github.com/gohugoio/hugo/vendor/github.com/spf13/cobra/command.go:726 +0x339
github.com/gohugoio/hugo/commands.Execute()
        /Users/bep/go/src/github.com/gohugoio/hugo/commands/hugo.go:172 +0x60
main.main()
        /Users/bep/go/src/github.com/gohugoio/hugo/main.go:27 +0x36

Interestingly, if you use a trailing slash on the layouts directory, you see a fencepost error in the path:

MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --layoutDir layouts/ --quiet
ERROR 2017/07/13 00:10:28 Failed to resolve template in path "/tmp/hugotest/layouts/index.html": open /tmp/hugotest/layouts/ndex.html: no such file or directory

Also interesting, if you don't specify a layouts directory, everything works fine:

MacBook-Pro:/tmp/hugotest> hugo --themesDir ./themes/ --quiet
MacBook-Pro:/tmp/hugotest>

That a --layoutDir argument triggers it makes sense given that the stack trace points at line 448 of hugo/tpl/tplimpl/template.go which is pretty explicitly operating on the path of the layout directory:

template.go lines 446 - 448:

li := strings.LastIndex(path, layoutDir) + len(layoutDir) + 1
relPath := path[li:]
templateDir := path[:li-len(layoutDir)-1]

@bep bep modified the milestones: v0.26, v0.27 Aug 6, 2017

@bep bep modified the milestones: v0.27, v0.28 Sep 7, 2017

@bep bep removed this from the v0.28 milestone Sep 21, 2017

@bep bep modified the milestones: v0.31, v0.32 Nov 12, 2017

@bep bep modified the milestones: v0.32, v0.33 Dec 16, 2017

@bep bep modified the milestones: v0.33, v0.34 Jan 11, 2018

@bep bep modified the milestones: v0.34, v0.35, v0.36 Jan 22, 2018

@bep bep modified the milestones: v0.36, v0.37 Feb 3, 2018

@bep bep modified the milestones: v0.37, v0.38 Feb 11, 2018

@bep bep modified the milestones: v0.38, v0.39 Feb 21, 2018

@bep bep modified the milestones: v0.39, v0.40 Apr 9, 2018

@bep bep modified the milestones: v0.40, v0.41 Apr 20, 2018

@bep bep modified the milestones: v0.41, v0.42 May 4, 2018

@bep bep modified the milestones: v0.42, v0.43 Jun 5, 2018

@dominique-mueller

This comment has been minimized.

Show comment
Hide comment
@dominique-mueller

dominique-mueller Jun 29, 2018

Any news on this? I still have to maintain separate config files for Windows (my working machine) and Linux (the CI).

dominique-mueller commented Jun 29, 2018

Any news on this? I still have to maintain separate config files for Windows (my working machine) and Linux (the CI).

@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018

@bep bep modified the milestones: v0.44, v0.45, v0.46 Jul 10, 2018

@bep bep modified the milestones: v0.46, v0.47, v0.48 Aug 3, 2018

@bep bep modified the milestones: v0.48, v0.49 Aug 22, 2018

@bep bep modified the milestones: v0.49, v0.50 Sep 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment