[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!


#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.