Hugo 0.40.3 Netlify Build Error (Cont.)

I’m still running an old version of Hugo and recently Netlify changed their build image which prevented my site from building due to some incompatibility described in my previous post on the subject.

I received some help and was able to get my site building again with a change to my Netlify.toml which appears to route around the problem by retrieving the version the correct version of hugo to build my site that Netlify’s build image is unable to do.

Two days later it stopped building again. I feel like something change on their end as it was building fine right before that. The build logs are below.

Im working on a upgrade path to get my site to a newer build, but at this point I cant build my site and wondered what I can do until I I get my site upgrade to a newer version of hugo or migrate my site to an more recent installation of hugo.

7:06:37 PM: Netlify Build                                                 
7:06:37 PM: ────────────────────────────────────────────────────────────────
7:06:37 PM: ​
7:06:37 PM: ❯ Version
7:06:37 PM:   @netlify/build 35.8.4
7:06:37 PM: ​
7:06:37 PM: ❯ Flags
7:06:37 PM:   accountId: 5a32f1ff0b79b70b038bcd38
7:06:37 PM:   baseRelDir: true
7:06:37 PM:   buildId: 69a7313363e3fd000847c4af
7:06:37 PM:   deployId: 69a7313363e3fd000847c4b1
7:06:38 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:06:38 PM: ​
7:06:38 PM: ❯ Current directory
7:06:38 PM:   /opt/build/repo
7:06:38 PM: ​
7:06:38 PM: ❯ Config file
7:06:38 PM:   /opt/build/repo/netlify.toml
7:06:38 PM: ​
7:06:38 PM: ❯ Context
7:06:38 PM:   production
7:06:38 PM: ​
7:06:38 PM: build.command from netlify.toml                               
7:06:38 PM: ────────────────────────────────────────────────────────────────
7:06:38 PM: ​
7:06:38 PM: $ mkdir -p "${HOME}/.local/bin" && curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION_DOWNLOAD}/hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && tar -C "${HOME}/.local/bin" -xf "hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && rm "hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && git config core.quotepath false && export PATH="${HOME}/.local/bin:${PATH}" && hugo --gc --baseURL "${URL}"
7:06:38 PM:   
7:06:38 PM: tar: This does not look like a tar archive
7:06:38 PM: gzip: stdin: not in gzip format
7:06:38 PM: tar: Child returned status 1
7:06:38 PM: tar: Error is not recoverable: exiting now
7:06:38 PM: ​
7:06:38 PM: "build.command" failed                                        
7:06:38 PM: ────────────────────────────────────────────────────────────────
7:06:38 PM: ​
7:06:38 PM:   Error message
7:06:38 PM:   Command failed with exit code 2: mkdir -p "${HOME}/.local/bin" && curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION_DOWNLOAD}/hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && tar -C "${HOME}/.local/bin" -xf "hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && rm "hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && git config core.quotepath false && export PATH="${HOME}/.local/bin:${PATH}" && hugo --gc --baseURL "${URL}" (https://ntl.fyi/exit-code-2)
7:06:38 PM: ​​
7:06:38 PM:   Error location
7:06:38 PM:   In build.command from netlify.toml:
7:06:38 PM:   mkdir -p "${HOME}/.local/bin" && curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION_DOWNLOAD}/hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && tar -C "${HOME}/.local/bin" -xf "hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && rm "hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz" && git config core.quotepath false && export PATH="${HOME}/.local/bin:${PATH}" && hugo --gc --baseURL "${URL}"
7:06:38 PM: ​​
7:06:38 PM:   Resolved config
7:06:38 PM:   build:
7:06:38 PM:     command: "mkdir -p \"${HOME}/.local/bin\" && curl -sLJO
      \"https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION_DOWNLO\
      AD}/hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz\" && tar -C
      \"${HOME}/.local/bin\" -xf
      \"hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz\" && rm
      \"hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz\" && git config
      core.quotepath false && export PATH=\"${HOME}/.local/bin:${PATH}\" && hugo
      --gc --baseURL \"${URL}\"
​
7:06:38 PM:       \  "
    commandOrigin: config
7:06:38 PM:     environment:
7:06:38 PM:       - SITE_RECAPTCHA_KEY
7:06:38 PM:       - SITE_RECAPTCHA_SECRET
7:06:38 PM:       - HUGO_VERSION_DOWNLOAD
7:06:38 PM:     publish: /opt/build/repo/public
7:06:38 PM:     publishOrigin: config
7:06:38 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:06:38 PM: Failing build: Failed to build site
7:06:38 PM: Finished processing build request in 9.784s

Also as an update. I contacted Netlify support and they asked me to try and change the command so it fails more gracefully. They think its failing due to some times its not downloading the file correctly, but I dont think thats it. The email is below.

I tried changing the command with the code the specificed, but it fails with the same error.

our case with Netlify Support (521156) has a new response, included below. If you have any follow-up questions or comments, please reply to this email.

Hi Scott,

Thanks for confirming the exact netlify.toml.

Given that you’re already pinned to HUGO_VERSION_DOWNLOAD = "0.43.3" and this was working previously, the most likely issue is that the download step is no longer consistently retrieving the actual .tar.gz archive from GitHub (for example: GitHub returning an HTML error page, a transient CDN error, or an incomplete/corrupted download). When that happens, the next step tries to extract a file that isn’t a valid gzip/tar archive, and the build fails.

This isn’t something we can “fix” purely on Netlify’s side, because the command is pulling an external artifact during the build. The good news is we can make the build command more defensive so it fails fast with a clearer error (and typically resolves intermittent download issues).

Please update your command to:

command = “”"
set -euo pipefail &&
mkdir -p “${HOME}/.local/bin” &&
curl -fSL --retry 3 --retry-delay 2 -o “hugo_extended_${HUGO_VERSION_DOWNLOAD}Linux-64bit.tar.gz”
https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION_DOWNLOAD}/hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz” &&
tar -C “${HOME}/.local/bin” -xzf “hugo_extended${HUGO_VERSION_DOWNLOAD}Linux-64bit.tar.gz” &&
rm “hugo_extended${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz” &&
git config core.quotepath false &&
export PATH=“${HOME}/.local/bin:${PATH}” &&
hugo --gc --baseURL “${URL}”
“”"

We went through this a few days ago. Here’s what I posted:

https://discourse.gohugo.io/t/hugo-0-40-3-netlify-build-error/56764/14

That works great. Note that the version is set to 0.40.3.

But you’re using a different command:

curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION_DOWNLOAD}/hugo_extended_${HUGO_VERSION_DOWNLOAD}_Linux-64bit.tar.gz

See the word “extended” ? We didn’t start building extended releases until v0.43.

I remember and I copied your code right into the netlify.toml. It was working and then it stopped. I updated it and try again but im not sure whats happening.

Please copy and paste your entire netlify configuration file here.

Ok I think I am having some problems with my local commit env. The changes are not being pushed to the server. Sorry for missing that. Im looking into it.

So for some reason my tool was failing to comit changes. I fixed that and the command is working. Thank you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.