[FIXED in 0.42.1] Regression in "hugo server" Hugo 0.42


#1

I see a regression in Hugo 0.42 (verified that this error wasn’t on 0.41). And this is without using the theme composition feature.

Gitlab is down ATM, so cannot point to the repo yet … but here are some details.

The first build of hugo server is fine:

                   | EN
+------------------+-----+
  Pages            | 777
  Paginator pages  |  18
  Non-page files   |  15
  Static files     | 187
  Processed images |   0
  Aliases          |   6
  Sitemaps         |   1
  Cleaned          |   0

Total in 1985 ms
Watching for changes in /home/kmodi/hugo/scripter.co/{content,data,layouts,static,themes}
Watching for config changes in /home/kmodi/hugo/scripter.co/config.toml
Watching for config changes in /home/kmodi/hugo/scripter.co/themes/refined/config.toml
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

But when I change a content file, I get:

Change detected, rebuilding site
2018-06-12 12:38:05.386 -0400
Source changed "/home/kmodi/hugo/scripter.co/content/posts/time-formatting-in-go/index.md": WRITE
ERROR 2018/06/12 12:38:05 Failed to render "_default/list.html": runtime error: invalid memory address or nil pointer dereference
Total in 767 ms
ERROR 2018/06/12 12:38:06 Failed to rebuild site: logged 1 error(s)

Interestingly, even though it says Failed to rebuild site: logged 1 error(s), the site rebuilds fine… I think … because the page live reloads with new content.

Here’s the relevant snippet from my _default/list.html:

    {{ range .Pages.GroupByDate "2006" }}
        <h2 id="{{ .Key }}">{{ .Key }}</h2>
        <ul class="no-bullets">
            {{ range .Pages }}
                {{ .Render "li" }}
            {{ end }}
        </ul>
    {{ end }}

If I remove the {{ .Render "li" }} line, the error goes away.

But my _default/li.html is this… could something in there break in 0.42?:

<li class="h-entry li">
    {{ partial "date-maybe.html" (dict "page" . "fmt" "01/02" "fmtupd" "2006/01/02") }}
    <span class="p-name post-title no-text-decoration"><a class="u-url" href='{{ .Permalink }}'>{{ .Title }}</a></span>
    <div class="right">
        {{ partial "taxo-buttons.html" . }}
    </div>
    <div class="clear-float"></div>
</li>

I thought so… but emptying the li.html still gives that error!


[FIXED in 0.49] Traceback on "hugo server" reload (started with hugo 0.45)
#2

I suspect this is actually a fix and not a regression.


#3

Even if I set li.html to "a", I get that error.

On closer inspection, looks like it fails on generating a “posts” section, but generates a “notes” section on my site just fine (Gitlab is still down).

Any possible hints why a Render of li.html with just “a” could fail? In the meanwhile, I will try to hunt down the content file(s) in posts/ that’s causing this problem…


#4

It looks like some race condition to me…

No error here:

Change detected, rebuilding site
2018-06-12 13:46:27.359 -0400
Source changed "/home/kmodi/hugo/scripter.co/content/posts/follow-up-golang-quirk-number-strings-starting-with-0-are-octals/index.md": WRITE
Total in 645 ms

Save the file, and error shows up:

Change detected, rebuilding site
2018-06-12 13:46:35.359 -0400
Source changed "/home/kmodi/hugo/scripter.co/content/posts/follow-up-golang-quirk-number-strings-starting-with-0-are-octals/index.md": WRITE
ERROR 2018/06/12 13:46:35 Failed to render "_default/list.html": runtime error: invalid memory address or nil pointer dereference
Total in 610 ms
ERROR 2018/06/12 13:46:35 Failed to rebuild site: logged 1 error(s)

#5

Gitlab seems to be up now… Below recreates the error:

git clone --recurse-submodules https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io foo
cd foo
cd themes/refined
git pull # just in case
git checkout pre-theme-component-split # to switch to the theme version that works on Hugo v0.41 too (latest version has theme components)
cd ../..
hugo server 

Note the use of –recurse-submodules.

Now change any content file, like content/posts/fragmentions/index.md, and you will get:

Change detected, rebuilding site
2018-06-12 13:54:11.377 -0400
Source changed "/home/kmodi/sandbox/hugo/foo/content/posts/fragmentions/index.md": WRITE
ERROR 2018/06/12 13:54:11 Failed to render "_default/list.html": runtime error: invalid memory address or nil pointer dereference
Total in 681 ms
ERROR 2018/06/12 13:54:12 Failed to rebuild site: logged 1 error(s)

Now if you run hugo server using Hugo 0.41, and edit the same index.md file, you will not get this error.


#6

The error I get is not helpful and doesn’t tell what’s wrong… and the complete build worked fine on 0.41 (both hugo and hugo server) … I’ll keep digging. But it will be great if you try out recreating the above steps and may be end up finding a fix.


Update: The issue is only with hugo server. Running hugo works on v0.42. I even deployed a new post using v0.43-DEV on my blog, and that worked fine. But during development, hugo server has now stopped publishing the “posts” section.


#7

It’s this commit: https://github.com/gohugoio/hugo/commit/dc4226a8b27e03e31068fc945daab885d3819d04

Building using the commit before that fixes this problem. I even updated to the latest 0.43-DEV and rebuilt hugo after reverting just that one commit, and that resolves this issue too.

If it helps in figuring out the root cause of this problem, I set disableFastRender = true in my site config.


#8

Thanks for the detailed report.


#9

I just got this a little while ago and was just investigating when I found this. Looks like you’ve got it covered, but if I can be of any help, let me know.


#10

There’s definitely something fishy going on.

I’ve got the same error. I’ve had a break from coding in almost a month, and when I got back, I got the nil pointer error when running hugo server. I haven’t made any changes. For me it looks like something new introduced in version 0.40.3 or newer (My last commit was on May 8th).

I’ve just tested that 0.40.2 works.

0.40.3 burps out the error, but then it serves the site (with errors - missing footers on some pages).

0.41 and 0.42 doesn’t work. Not even plain hugo just to build the site.


#11

You can get the error with the latest version of hugo and my test repo here: https://github.com/jrisch/hugo-test


#12

@jrisch your issue is different. Your site also failed in Hugo 0.41, which isn’t saying it isn’t a bug – just not the same and not a regression from the recent release. You should open a separate issue for that on GitHub and we will eventually look at it. But from my first look into it: “.Render” is not currently supported for pages inside bundles. Maybe it should be, and we should at least improve the error message.


#13

@kaushalmodi I can reproduce this with you site. I will fix this, but I want to add that this problem was probably there also in earlier versions of Hugo, but with a slightly more subtle and silent behaviour. I will try to explain in the GH issue.


#14

Thanks! I confirm the fix.


#15

Hi @bep Actually the test site works with 0.40.2 but all newer versions fail, just with different outcomes.


#16

I am publishing it here, because i suspect this is the same cause. Let me know if it is the wrong place.

  • Hugo 0.48 on MacOSX + long time site building flawlessly since early hugo versions.
  • hugo server was fine on 0.48, until i added a custom RSS feed (and a layout/_default/change-rss.xml if it can help identifying the problem)
  • suddenly a rebuild produce a stack trace + hugo still runs but no pages rendered on browser.
  • hugo builds without any problem.
  • If I revert my commit just before doing my custom RSS file, hugo server works flawlessly.
Change detected, rebuilding site
2018-10-09 11:38:02.598 +0200
Source changed "/Users/didiergeorgieff/Documents/Git/documentation/doc-adhoc-gti/adhoc/content/reference/utilitaires/chorus/_index.md": WRITE
ERROR 2018/10/09 11:38:02 Failed to render "_default/list.html": runtime error: invalid memory address or nil pointer dereference
ERROR 2018/10/09 11:38:02 Stack Trace:
goroutine 451 [running]:
...
The full sttacktrace

Change detected, rebuilding site
2018-10-09 11:38:02.598 +0200
Source changed “/Users/didiergeorgieff/Documents/Git/documentation/doc-adhoc-gti/adhoc/content/reference/utilitaires/chorus/_index.md”: WRITE
ERROR 2018/10/09 11:38:02 Failed to render “_default/list.html”: runtime error: invalid memory address or nil pointer dereference
ERROR 2018/10/09 11:38:02 Stack Trace:
goroutine 451 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0x4cc0dd3, 0x17)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/page.go:285 +0x76
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc006bc37d0, 0xc000118300)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/site.go:1741 +0x135
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006bc36c0)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006bc2860)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006bc1bb8)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/gohugoio/hugo/hugolib.(*Page).Sections(0x0, 0x0, 0x0, 0x0)
/private/tmp/hu
ERROR 2018/10/09 11:38:02 Stack Trace:
goroutine 448 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0x4cc0dd3, 0x17)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/page.go:285 +0x76
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc006bbb7d0, 0xc000118300)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/site.go:1741 +0x135
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006bbb6c0)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006bba860)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006bb9bb8)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/gohugoio/hugo/hugolib.(*Page).Sections(0x0, 0x0, 0x0, 0x0)
/private/tmp/hu
ERROR 2018/10/09 11:38:02 Stack Trace:
goroutine 450 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0x4cc0dd3, 0x17)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/page.go:285 +0x76
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc005b4d7d0, 0xc000118300)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/site.go:1741 +0x135
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc005b4d6c0)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc005b4c860)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc005b4bbb8)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/gohugoio/hugo/hugolib.(*Page).Sections(0x0, 0x0, 0x0, 0x0)
/private/tmp/hu
ERROR 2018/10/09 11:38:02 Stack Trace:
goroutine 449 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0x4cc0dd3, 0x17)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/page.go:285 +0x76
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc006a997d0, 0xc000118300)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/site.go:1741 +0x135
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006a996c0)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006a98860)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc006a97bb8)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/gohugoio/hugo/hugolib.(*Page).Sections(0x0, 0x0, 0x0, 0x0)
/private/tmp/hu
ERROR 2018/10/09 11:38:02 Failed to render “_default/single.html”: runtime error: invalid memory address or nil pointer dereference
ERROR 2018/10/09 11:38:02 Failed to render “index.html”: runtime error: invalid memory address or nil pointer dereference
ERROR 2018/10/09 11:38:02 Failed to render “404.html”: runtime error: invalid memory address or nil pointer dereference
ERROR 2018/10/09 11:38:02 Stack Trace:
goroutine 387 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0x4cc0dd3, 0x17)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/page.go:285 +0x76
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc0054712c0, 0xc000118300)
/private/tmp/hugo-20180829-34153-1opw9us/hugo-0.48/src/github.com/gohugoio/hugo/hugolib/site.go:1741 +0x135
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc0054711b0)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc005470350)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
text/template.errRecover(0xc00546f6a8)
/usr/local/Cellar/go/1.11/libexec/src/text/template/exec.go:160 +0x1d0
panic(0x4b8e560, 0x55f7650)
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9
github.com/gohugoio/hugo/hugolib.(*Page).Sections(0x0, 0x0, 0x0, 0x0)
/private/tmp/hu
Total in 298 ms
ERROR 2018/10/09 11:38:02 Failed to rebuild site: logged 9 error(s)


#17

I investigate a bit and tested every hugo version I have (thanks to brew switch) on my Mac.

  • version <= 0.44 = no traceback. Server reload gracefully on every .md change.
  • version >= 0.45 = same traceback

Hope this helps you to find the problem @kaushalmodi

Let me know if you need more information (repo is not public but i can send a zip without problem if it would help debug)


#18

Please don’t repurpose slightly relevant, but very old threads.


#19

#20