paige: Invalid memory address or nil pointer dereference on Windows

When trying to build exampleSite on Windows, it errors, but in Ubuntu, it is working.

cd exampleSite
hugo --themesDir ../..

Start building sites …
hugo v0.109.0-47b12b83e636224e5e601813ff3e6790c191e371 windows/amd64 BuildDate=2022-12-23T10:38:11Z VendorInfo=gohugoio
ERROR 2023/01/10 12:54:41 render of "page" failed: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\_default\baseof.html:5:7": execute of template failed: template: _default/single.html:5:7: executing "_default/single.html" at <partial "paige/head.html" .>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\head.html:4:7": execute of template failed: template: partials/paige/head.html:4:7: executing "partials/paige/head.html" at <partial "paige/links.html" .>: error calling partial: execute of template failed: template: partials/paige/links.html:16:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.style.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" .Site.Params.paige.bootstrap.style.link_integrity "remote" .Site.Params.paige.bootstrap.style.remote)>: error calling partial: execute of template failed: template: partials/paige/link.html:11:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $href)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:11:25": execute of template failed: template: partials/paige/func-resource.html:11:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
ERROR 2023/01/10 12:54:41 render of "page" failed: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\_default\baseof.html:5:7": execute of template failed: template: _default/single.html:5:7: executing "_default/single.html" at <partial "paige/head.html" .>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\head.html:4:7": execute of template failed: template: partials/paige/head.html:4:7: executing "partials/paige/head.html" at <partial "paige/links.html" .>: error calling partial: execute of template failed: template: partials/paige/links.html:16:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.style.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" .Site.Params.paige.bootstrap.style.link_integrity "remote" .Site.Params.paige.bootstrap.style.remote)>: error calling partial: execute of template failed: template: partials/paige/link.html:11:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $href)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:11:25": execute of template failed: template: partials/paige/func-resource.html:11:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
ERROR 2023/01/10 12:54:41 render of "page" failed: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\_default\baseof.html:5:7": execute of template failed: template: _default/paige/search.html:5:7: executing "_default/paige/search.html" at <partial "paige/head.html" .>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\head.html:4:7": execute of template failed: template: partials/paige/head.html:4:7: executing "partials/paige/head.html" at <partial "paige/links.html" .>: error calling partial: execute of template failed: template: partials/paige/links.html:16:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.style.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" .Site.Params.paige.bootstrap.style.link_integrity "remote" .Site.Params.paige.bootstrap.style.remote)>: error calling partial: execute of template failed: template: partials/paige/link.html:11:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $href)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:11:25": execute of template failed: template: partials/paige/func-resource.html:11:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
ERROR 2023/01/10 12:54:41 render of "page" failed: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\_default\baseof.html:5:7": execute of template failed: template: _default/single.html:5:7: executing "_default/single.html" at <partial "paige/head.html" .>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\head.html:4:7": execute of template failed: template: partials/paige/head.html:4:7: executing "partials/paige/head.html" at <partial "paige/links.html" .>: error calling partial: execute of template failed: template: partials/paige/links.html:16:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.style.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" .Site.Params.paige.bootstrap.style.link_integrity "remote" .Site.Params.paige.bootstrap.style.remote)>: error calling partial: execute of template failed: template: partials/paige/link.html:11:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $href)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:11:25": execute of template failed: template: partials/paige/func-resource.html:11:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
Error: Error building site: failed to render pages: render of "page" failed: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\_default\baseof.html:5:7": execute of template failed: template: _default/single.html:5:7: executing "_default/single.html" at <partial "paige/head.html" .>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\head.html:4:7": execute of template failed: template: partials/paige/head.html:4:7: executing "partials/paige/head.html" at <partial "paige/links.html" .>: error calling partial: execute of template failed: template: partials/paige/links.html:16:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.style.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" .Site.Params.paige.bootstrap.style.link_integrity "remote" .Site.Params.paige.bootstrap.style.remote)>: error calling partial: execute of template failed: template: partials/paige/link.html:11:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $href)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:11:25": execute of template failed: template: partials/paige/func-resource.html:11:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
Total in 246 ms

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 24 (11 by maintainers)

Most upvoted comments

I have successfully built this theme on Windows 11 and Windows 10, including on a GitHub runner running Windows Server

@AnimMouse Thank you for your report!

This is the first time I have encountered a Hugo theme that requires npm install to work

I thought it would be good to keep deps out of the repo to make it smaller. It’s already too large, in my opinion. I’m going to try to slim it down in the future. Fortunately, Hugo supports this.

I was wondering how can I run this theme inside Cloudflare Pages, like if I should include the node_modules folder inside the repository

How are you deploying to Cloudflare Pages?

Are you using https://github.com/cloudflare/pages-action in a GitHub workflow? If so, the doc there says you can put your own build actions in the middle:

on: [push]

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    name: Publish to Cloudflare Pages
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      # Run a build step here if your project requires

      - name: Publish to Cloudflare Pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: YOUR_ACCOUNT_ID
          projectName: YOUR_PROJECT_NAME
          directory: YOUR_ASSET_DIRECTORY
          # Optional: Enable this if you want to have GitHub Deployments triggered
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}

You can put npm install there. For example:

- name: Build
  run: |
    npm build
    hugo build # ...flags

All the GitHub runners have npm installed.

See the changes to .github/workflows/pages.yml in https://github.com/willfaught/paige/commit/24be3b3230046642f55bcea8a3b5e577e818a2ed for an example of how Paige does it for the example site.

Thanks for the bug fix and the theme!

My pleasure.

@rogerssam Take a look at the current menu of the exampleSite. “Content” is the name of a section that shows how standard content is displayed in the theme. It’s adjacent to other sections that show off the theme’s shortcodes (“Shortcodes”), layouts (“Layouts”), and so on. There’s no single “posts” or “blog” section that can correspond to the “content” section in this context.

Some alternative section names that seemed worse than “Content” to me:

  • HTML
  • Media
  • Display
  • Data

I couldn’t think of anything better. 🤷‍♂️

You could call the section name “List-style content”? I realise it’s long (not ideal), but perhaps clearer what it’s demoing? Or maybe even just “Lists” or “Articles”? I would still suggest that “Posts” would give that information to new users because I figure most people are going to want to use that section for blog-style content, so making it clear that’s where/how it will display is probably useful.

The other sections also have lists of links to pages in those sections, so it would be confusing for only one of them to be called that. That name also wouldn’t describe what kind of pages are in that section. Hence, the current situation. 😃 Thanks for your suggestions.

Yeah fair comment, I see what you mean.

You could call the section name “List-style content”? I realise it’s long (not ideal), but perhaps clearer what it’s demoing? Or maybe even just “Lists” or “Articles”? I would still suggest that “Posts” would give that information to new users because I figure most people are going to want to use that section for blog-style content, so making it clear that’s where/how it will display is probably useful.

You could also change this line to something like “Demonstrations of Paige list-style content (suitable for blogs, articles etc)”.

At the end of the day it probably doesn’t matter too much 😃 Thanks for your work with this theme - it’s very impressive!

I agree with this, instead of exampleSite/content/content, it should be exampleSite/content/posts, as content/content is confusing.

I wasn’t thrilled with the name, either, but I couldn’t think of a better one. Suggestions are welcome.

Thanks, @rogerssam!

@AnimMouse @luisimasd @Dekker500 Does it work for you?

After some debugging, I might have a fix. The error still happens on a GitHub runner running Windows Server, but it doesn’t happen on a PC running Windows 11. Would someone please test v0.39.0 and report back?

I can confirm this works for me with a blank site using the default exampleSite config and content. Thanks!

After some debugging, I might have a fix. The error still happens on a GitHub runner running Windows Server, but it doesn’t happen on a PC running Windows 11. Would someone please test v0.39.0 and report back?

@rogerssam Were you using Windows too?

Can either of you report the site/page config you used?

We haven’t edited any configuration, I basically run Hugo on your exampleSite folder on Windows.

Unfortunately, I don’t have a Windows computer with WSL set up, so I can’t repro the issue directly.

Since I saw you use GitHub Actions for CI/CD, you can use GitHub Actions’ Windows runners by using runs-on: windows-latest on your current workflow. If you have a Windows computer, you don’t need WSL, you can run it on command prompt.

The logs below are created on GitHub Actions Windows runners for clean reproducible environment.

Logs as of be578407421b686b9a6f7ef36d653a73fa6ffbe5:

git clone https://github.com/willfaught/paige.git
cd paige/exampleSite
hugo --themesDir ../..

Start building sites …
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168 windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
Error: Error building site: "D:\a\github-actions-testing\github-actions-testing\paige\exampleSite\content\shortcodes\gallery\index.md:27:1": failed to render shortcode "paige/gallery": failed to process shortcode: execute of template failed: template: shortcodes/paige/gallery.html:49:23: executing "shortcodes/paige/gallery.html" at <partial "paige/img.html" (dict "class" "img-fluid" "height" $height "maxheight" $maxheight "maxwidth" $maxwidth "method" $method "options" $options "resource" $resource "src" $image "width" $width)>: error calling partial: execute of template failed: template: partials/paige/img.html:30:23: executing "partials/paige/img.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $src)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
Total in 750 ms

Hugo extended:

git clone https://github.com/willfaught/paige.git
cd paige/exampleSite
hugo --themesDir ../..

Start building sites …
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
Error: Error building site: "D:\a\github-actions-testing\github-actions-testing\paige\exampleSite\content\shortcodes\gallery\index.md:27:1": failed to render shortcode "paige/gallery": failed to process shortcode: execute of template failed: template: shortcodes/paige/gallery.html:49:23: executing "shortcodes/paige/gallery.html" at <partial "paige/img.html" (dict "class" "img-fluid" "height" $height "maxheight" $maxheight "maxwidth" $maxwidth "method" $method "options" $options "resource" $resource "src" $image "width" $width)>: error calling partial: execute of template failed: template: partials/paige/img.html:30:23: executing "partials/paige/img.html" at <partial "paige/func-resource.html" (dict "page" $page "url" $src)>: error calling partial: "D:\a\github-actions-testing\github-actions-testing\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
Total in 822 ms

I won’t be able to test until the 20th, however the site config was the one you provided. The course shown above is the exact sequence I followed in a brand new folder.

Will report after the 20th… Sorry!

I am seeing the same problem.

The problem is showing on a raw, clean base new site created with your template, with no modifications.

PS C:\hugo\paige\exampleSite> hugo version
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168 windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
PS C:\hugo> git clone https://github.com/willfaught/paige paige
Cloning into 'paige'...
remote: Enumerating objects: 4474, done.
remote: Counting objects: 100% (1785/1785), done.
remote: Compressing objects: 100% (370/370), done.
Receiving objects: 100% (4474/4474), 8.92 MiB | 2.95 MiB/s, done.
remote: Total 4474 (delta 1384), reused 1685 (delta 1317), pack-reused 2689
Resolving deltas: 100% (2830/2830), done.
PS C:\hugo> cd paige
PS C:\hugo\paige> cd .\exampleSite\
PS C:\hugo\paige\exampleSite> hugo --themesDir ../..
Start building sites …
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168 windows/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
ERROR 2023/02/10 07:03:40 render of "page" failed: "C:\hugo\paige\layouts\_default\baseof.html:10:7": execute of template failed: template: _default/paige/search.html:10:7: executing "_default/paige/search.html" at <partial "paige/head.html" $page>: error calling partial: "C:\hugo\paige\layouts\partials\paige\head.html:12:7": execute of template failed: template: partials/paige/head.html:12:7: executing "partials/paige/head.html" at <partial "paige/links.html" $page>: error calling partial: execute of template failed: template: partials/paige/links.html:21:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" ($page.Param "paige.bootstrap.style.link_href" | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" ($page.Param "paige.bootstrap.style.link_integrity") "raw" ($page.Param "paige.bootstrap.style.raw"))>: error calling partial: execute of template failed: template: partials/paige/link.html:13:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" (relLangURL $href))>: error calling partial: "C:\hugo\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
ERROR 2023/02/10 07:03:40 render of "page" failed: "C:\hugo\paige\layouts\_default\baseof.html:10:7": execute of template failed: template: _default/single.html:10:7: executing "_default/single.html" at <partial "paige/head.html" $page>: error calling partial: "C:\hugo\paige\layouts\partials\paige\head.html:12:7": execute of template failed: template: partials/paige/head.html:12:7: executing "partials/paige/head.html" at <partial "paige/links.html" $page>: error calling partial: execute of template failed: template: partials/paige/links.html:21:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" ($page.Param "paige.bootstrap.style.link_href" | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" ($page.Param "paige.bootstrap.style.link_integrity") "raw" ($page.Param "paige.bootstrap.style.raw"))>: error calling partial: execute of template failed: template: partials/paige/link.html:13:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" (relLangURL $href))>: error calling partial: "C:\hugo\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
ERROR 2023/02/10 07:03:40 render of "page" failed: "C:\hugo\paige\layouts\_default\baseof.html:10:7": execute of template failed: template: _default/single.html:10:7: executing "_default/single.html" at <partial "paige/head.html" $page>: error calling partial: "C:\hugo\paige\layouts\partials\paige\head.html:12:7": execute of template failed: template: partials/paige/head.html:12:7: executing "partials/paige/head.html" at <partial "paige/links.html" $page>: error calling partial: execute of template failed: template: partials/paige/links.html:21:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" ($page.Param "paige.bootstrap.style.link_href" | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" ($page.Param "paige.bootstrap.style.link_integrity") "raw" ($page.Param "paige.bootstrap.style.raw"))>: error calling partial: execute of template failed: template: partials/paige/link.html:13:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" (relLangURL $href))>: error calling partial: "C:\hugo\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
ERROR 2023/02/10 07:03:40 render of "page" failed: "C:\hugo\paige\layouts\_default\baseof.html:10:7": execute of template failed: template: _default/single.html:10:7: executing "_default/single.html" at <partial "paige/head.html" $page>: error calling partial: "C:\hugo\paige\layouts\partials\paige\head.html:12:7": execute of template failed: template: partials/paige/head.html:12:7: executing "partials/paige/head.html" at <partial "paige/links.html" $page>: error calling partial: execute of template failed: template: partials/paige/links.html:21:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" ($page.Param "paige.bootstrap.style.link_href" | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" ($page.Param "paige.bootstrap.style.link_integrity") "raw" ($page.Param "paige.bootstrap.style.raw"))>: error calling partial: execute of template failed: template: partials/paige/link.html:13:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" (relLangURL $href))>: error calling partial: "C:\hugo\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
Error: Error building site: failed to render pages: render of "page" failed: "C:\hugo\paige\layouts\_default\baseof.html:10:7": execute of template failed: template: _default/single.html:10:7: executing "_default/single.html" at <partial "paige/head.html" $page>: error calling partial: "C:\hugo\paige\layouts\partials\paige\head.html:12:7": execute of template failed: template: partials/paige/head.html:12:7: executing "partials/paige/head.html" at <partial "paige/links.html" $page>: error calling partial: execute of template failed: template: partials/paige/links.html:21:3: executing "partials/paige/links.html" at <partial "paige/link.html" (dict "href" ($page.Param "paige.bootstrap.style.link_href" | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" ($page.Param "paige.bootstrap.style.link_integrity") "raw" ($page.Param "paige.bootstrap.style.raw"))>: error calling partial: execute of template failed: template: partials/paige/link.html:13:21: executing "partials/paige/link.html" at <partial "paige/func-resource.html" (dict "page" $page "url" (relLangURL $href))>: error calling partial: "C:\hugo\paige\layouts\partials\paige\func-resource.html:14:25": execute of template failed: template: partials/paige/func-resource.html:14:25: executing "partials/paige/func-resource.html" at <resources.GetMatch>: error calling GetMatch: runtime error: invalid memory address or nil pointer dereference
Total in 1409 ms