Build command failed because of hugo version

Hi, my site is simple-site-from-codemon72
It is built with Hugo Theme Ananke and should get deployed from GitHub.
When I try to deploy I get this error message:

    3:16:00 PM: ┌───────────────────────────────────┐
    3:16:00 PM: │ 1. Build command from Netlify app │
    3:16:00 PM: └───────────────────────────────────┘
    3:16:00 PM: ​
    3:16:00 PM: $ hugo
    3:16:00 PM: ERROR 2020/11/03 14:16:00 ANANKE theme does not support Hugo version 0.54.0. Minimum version required is 0.55.0
    3:16:00 PM: Building sites … Total in 37 ms
    3:16:00 PM: Error: Error building site: logged 1 error(s)
    3:16:00 PM: ​
    3:16:00 PM: ┌─────────────────────────────┐
    3:16:00 PM: │ "build.command" failed │

(full version below)

Looks straightforward, but when I check my hugo version I should be alright: Hugo Static Site Generator v0.73.0
Do I need to choose a newer Hugo version somewhere on Netlify?
Any help appreciated, I can’t make any sense out of this error message.

Full build log:

4:37:32 PM: Build ready to start
4:37:34 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
4:37:34 PM: build-image tag: v3.4.1
4:37:34 PM: buildbot version: 9c8ae11ff96d61099561d579a91d03dc24930de5
4:37:34 PM: Building without cache
4:37:34 PM: Starting to prepare the repo for build
4:37:34 PM: No cached dependencies found. Cloning fresh repo
4:37:34 PM: git clone https://github.com/Codemon72/simple-site
4:37:35 PM: Preparing Git Reference refs/heads/master
4:37:37 PM: Starting build script
4:37:37 PM: Installing dependencies
4:37:37 PM: Python version set to 2.7
4:37:39 PM: v12.18.0 is already installed.
4:37:39 PM: Now using node v12.18.0 (npm v6.14.4)
4:37:39 PM: Started restoring cached build plugins
4:37:39 PM: Finished restoring cached build plugins
4:37:39 PM: Attempting ruby version 2.7.1, read from environment
4:37:41 PM: Using ruby version 2.7.1
4:37:41 PM: Using PHP version 5.6
4:37:41 PM: 5.2 is already installed.
4:37:41 PM: Using Swift version 5.2
4:37:41 PM: Started restoring cached go cache
4:37:41 PM: Finished restoring cached go cache
4:37:41 PM: go version go1.14.4 linux/amd64
4:37:41 PM: go version go1.14.4 linux/amd64
4:37:41 PM: Installing missing commands
4:37:41 PM: Verify run directory
4:37:42 PM: ​
4:37:42 PM: ┌─────────────────────────────┐
4:37:42 PM: │        Netlify Build        │
4:37:42 PM: └─────────────────────────────┘
4:37:42 PM: ​
4:37:42 PM: ❯ Version
4:37:42 PM:   @netlify/build 5.2.1
4:37:42 PM: ​
4:37:42 PM: ❯ Flags
4:37:42 PM:   deployId: 5fa1793c21a8bbf171df03c1
4:37:42 PM:   mode: buildbot
4:37:42 PM: ​
4:37:42 PM: ❯ Current directory
4:37:42 PM:   /opt/build/repo
4:37:42 PM: ​
4:37:42 PM: ❯ Config file
4:37:42 PM:   No config file was defined: using default values.
4:37:42 PM: ​
4:37:42 PM: ❯ Context
4:37:42 PM:   production
4:37:42 PM: ​
4:37:42 PM: ┌───────────────────────────────────┐
4:37:42 PM: │ 1. Build command from Netlify app │
4:37:42 PM: └───────────────────────────────────┘
4:37:42 PM: ​
4:37:42 PM: $ hugo
4:37:42 PM: ERROR 2020/11/03 15:37:42 ANANKE theme does not support Hugo version 0.54.0. Minimum version required is 0.55.0
4:37:42 PM: Building sites … Total in 27 ms
4:37:42 PM: Error: Error building site: logged 1 error(s)
4:37:42 PM: ​
4:37:42 PM: ┌─────────────────────────────┐
4:37:42 PM: │   "build.command" failed    │
4:37:42 PM: └─────────────────────────────┘
4:37:42 PM: ​
4:37:42 PM:   Error message
4:37:42 PM:   Command failed with exit code 255: hugo
4:37:42 PM: ​
4:37:42 PM:   Error location
4:37:42 PM:   In Build command from Netlify app:
4:37:42 PM:   hugo
4:37:42 PM: ​
4:37:42 PM:   Resolved config
4:37:42 PM:   build:
4:37:42 PM:     command: hugo
4:37:42 PM:     commandOrigin: ui
4:37:42 PM:     publish: /opt/build/repo/public
4:37:43 PM: Caching artifacts
4:37:43 PM: Started saving build plugins
4:37:43 PM: Finished saving build plugins
4:37:43 PM: Started saving pip cache
4:37:43 PM: Finished saving pip cache
4:37:43 PM: Started saving emacs cask dependencies
4:37:43 PM: Finished saving emacs cask dependencies
4:37:43 PM: Started saving maven dependencies
4:37:43 PM: Finished saving maven dependencies
4:37:43 PM: Started saving boot dependencies
4:37:43 PM: Finished saving boot dependencies
4:37:43 PM: Started saving go dependencies
4:37:43 PM: Finished saving go dependencies
4:37:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:37:45 PM: Failing build: Failed to build site
4:37:45 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:37:45 PM: Finished processing build request in 11.307732214s

Hi.

Try creating a file in your repository with the name netlify.toml and the contents as follows:

[build]
  command = "hugo"
  context = "production"
  publish = "public"

[context.production.environment]
  HUGO_VERSION = "0.78.0"
  HUGO_ENV = "production"

Thank you!
Where could I have found that in the docs?
(I’ve spent all day on this going through the docs on hugo and netlify.)

Hugo has it documented here: https://gohugo.io/hosting-and-deployment/hosting-on-netlify/

1 Like

Hi, I have been trying to deploy for some time and have the same build.command failed error. I matched my versions and made the above changes to the netlify.toml and still face issues

9:00:53 PM: ────────────────────────────────────────────────────────────────
9:00:53 PM: “build.command” failed
9:00:53 PM: ────────────────────────────────────────────────────────────────

9:00:53 PM: ​
9:00:53 PM: Error message
9:00:53 PM: Command failed with exit code 255: hugo
9:00:53 PM: ​
9:00:53 PM: Error location
9:00:53 PM: In build.command from netlify.toml:
9:00:53 PM: hugo
9:00:53 PM: ​
9:00:53 PM: Resolved config
9:00:53 PM: build:
9:00:53 PM: command: hugo
9:00:53 PM: commandOrigin: config
9:00:53 PM: environment:
9:00:53 PM: - HUGO_VERSION
9:00:53 PM: - HUGO_ENABLEGITINFO
9:00:53 PM: - HUGO_ENV
9:00:53 PM: publish: /opt/build/repo/public

could you show us your package.json please?

Hi Perry, thanks for the message. Apologies, but I am not sure understand? It is not a package but I am trying to build a Hugo website if that helps?

As you can see with the commit number, from the various sources I’ve read online, I have tried different edits to the .toml to no avail

A full build log would be more helpful than what you’ve posted.

Thank you. Apologies for misunderstanding. Here it is

9:33:22 PM: Build ready to start
9:33:24 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
9:33:24 PM: build-image tag: v3.7.6
9:33:24 PM: buildbot version: 96f6c6faf398b8f2b7e39c2c3c6a03ac4592e535
9:33:24 PM: Fetching cached dependencies
9:33:24 PM: Starting to download cache of 105.6KB
9:33:24 PM: Finished downloading cache in 71.478844ms
9:33:24 PM: Starting to extract cache
9:33:24 PM: Finished extracting cache in 9.250949ms
9:33:24 PM: Finished fetching cache in 81.039862ms
9:33:24 PM: Starting to prepare the repo for build
9:33:24 PM: Preparing Git Reference refs/heads/main
9:33:25 PM: Parsing package.json dependencies
9:33:27 PM: Starting build script
9:33:27 PM: Installing dependencies
9:33:27 PM: Python version set to 2.7
9:33:28 PM: v12.18.0 is already installed.
9:33:29 PM: Now using node v12.18.0 (npm v6.14.4)
9:33:29 PM: Started restoring cached build plugins
9:33:29 PM: Finished restoring cached build plugins
9:33:29 PM: Attempting ruby version 2.7.1, read from environment
9:33:31 PM: Using ruby version 2.7.1
9:33:31 PM: Using PHP version 5.6
9:33:31 PM: Installing Hugo 0.83.1
9:33:32 PM: hugo v0.83.1-5AFE0A57+extended linux/amd64 BuildDate=2021-05-02T14:38:05Z VendorInfo=gohugoio
9:33:32 PM: Started restoring cached go cache
9:33:32 PM: Finished restoring cached go cache
9:33:32 PM: go version go1.14.4 linux/amd64
9:33:32 PM: go version go1.14.4 linux/amd64
9:33:33 PM: Installing missing commands
9:33:33 PM: Verify run directory
9:33:34 PM: ​
9:33:34 PM: ────────────────────────────────────────────────────────────────
9:33:34 PM: Netlify Build
9:33:34 PM: ────────────────────────────────────────────────────────────────
9:33:34 PM: ​
9:33:34 PM: ❯ Version
9:33:34 PM: @netlify/build 11.18.0
9:33:34 PM: ​
9:33:34 PM: ❯ Flags
9:33:34 PM: deployId: 60a81912b66e800089fffbea
9:33:34 PM: ​
9:33:34 PM: ❯ Current directory
9:33:34 PM: /opt/build/repo
9:33:34 PM: ​
9:33:34 PM: ❯ Config file
9:33:34 PM: /opt/build/repo/netlify.toml
9:33:34 PM: ​
9:33:34 PM: ❯ Context
9:33:34 PM: production
9:33:35 PM: ​
9:33:35 PM: ❯ Installing plugins
9:33:35 PM: - netlify-plugin-hugo-cache-resources@0.2.1
9:33:36 PM: ​
9:33:36 PM: ❯ Loading plugins
9:33:36 PM: - netlify-plugin-hugo-cache-resources@0.2.1 from netlify.toml
9:33:36 PM: ​
9:33:36 PM: ──────────────────────────────────────────────────────────────────
9:33:36 PM: 1. onPreBuild command from netlify-plugin-hugo-cache-resources
9:33:36 PM: ──────────────────────────────────────────────────────────────────
9:33:36 PM: ​
9:33:37 PM: Checking if resources exist at “resources”
9:33:37 PM: No cache found for resources folder
9:33:37 PM: ​
9:33:37 PM: (netlify-plugin-hugo-cache-resources onPreBuild completed in 212ms)
9:33:37 PM: ​
9:33:37 PM: ────────────────────────────────────────────────────────────────
9:33:37 PM: 2. build.command from netlify.toml
9:33:37 PM: ────────────────────────────────────────────────────────────────
9:33:37 PM: ​
9:33:37 PM: $ hugo
9:33:37 PM: Total in 2 ms
9:33:37 PM: Error: module “starter-academic” not found; either add it as a Hugo Module or store it in “/opt/build/repo/themes”.: module does not exist
9:33:37 PM: ​
9:33:37 PM: ────────────────────────────────────────────────────────────────
9:33:37 PM: “build.command” failed
9:33:37 PM: ────────────────────────────────────────────────────────────────
9:33:37 PM: ​
9:33:37 PM: Error message
9:33:37 PM: Command failed with exit code 255: hugo
9:33:37 PM: ​
9:33:37 PM: Error location
9:33:37 PM: In build.command from netlify.toml:
9:33:37 PM: hugo
9:33:37 PM: ​
9:33:37 PM: Resolved config
9:33:37 PM: build:
9:33:37 PM: command: hugo
9:33:37 PM: commandOrigin: config
9:33:37 PM: environment:
9:33:37 PM: - HUGO_VERSION
9:33:37 PM: - HUGO_ENABLEGITINFO
9:33:37 PM: - HUGO_ENV
9:33:37 PM: publish: /opt/build/repo/public
9:33:37 PM: plugins:
9:33:37 PM: - inputs:
9:33:37 PM: debug: true
9:33:37 PM: origin: config
9:33:37 PM: package: netlify-plugin-hugo-cache-resources
9:33:37 PM: Caching artifacts
9:33:37 PM: Started saving build plugins
9:33:37 PM: Finished saving build plugins
9:33:37 PM: Started saving pip cache
9:33:37 PM: Finished saving pip cache
9:33:37 PM: Started saving emacs cask dependencies
9:33:37 PM: Finished saving emacs cask dependencies
9:33:37 PM: Started saving maven dependencies
9:33:37 PM: Finished saving maven dependencies
9:33:37 PM: Started saving boot dependencies
9:33:37 PM: Finished saving boot dependencies
9:33:37 PM: Started saving rust rustup cache
9:33:37 PM: Finished saving rust rustup cache
9:33:37 PM: Started saving go dependencies
9:33:37 PM: Finished saving go dependencies
9:33:40 PM: Creating deploy upload records
9:33:40 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:33:41 PM: Failing build: Failed to build site
9:33:41 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
9:33:41 PM: Finished processing build request in 16.84454693s

I think this line explains quite a bit. You need to add the theme to the themes folder. If you’ve added it and it’s still not working, we’d need to see your repo.

1 Like

Thank you so much. :blush:I solved it with your comment.