Hugo build error 255 despite using latest versions

I just updated my netlify.toml to include the latest version of Hugo (copied and pasted from Hugo’s Netlify example on Github). I also updated the build image to Ubuntu Focal 20.04 since the older one is being depreciated. Now I keep getting deploy fails like the one below. It works on my local machine with the same version of Hugo. I thought it was the --gc or --minify flags, but deleting them has no effect, which makes me think that the base Hugo command is failing. Any thoughts?

Site is https://www.polaine.com - please let me know any more info you might need.

5:20:11 PM:   "build.command" failed                                        
5:20:11 PM: ────────────────────────────────────────────────────────────────
5:20:11 PM: ​
5:20:11 PM:   Error message
5:20:11 PM:   Command failed with exit code 255: hugo --gc --minify (https://ntl.fyi/exit-code-255)
5:20:11 PM: ​
5:20:11 PM:   Error location
5:20:11 PM:   In build.command from netlify.toml:
5:20:11 PM:   hugo --gc --minify
5:20:11 PM: ​
5:20:11 PM:   Resolved config
5:20:11 PM:   build:
5:20:11 PM:     command: hugo --gc --minify
5:20:11 PM:     commandOrigin: config
5:20:11 PM:     environment:
5:20:11 PM:       - HUGO_VERSION
5:20:11 PM:       - HUGO_ENV
5:20:11 PM:       - HUGO_ENABLEGITINFO
5:20:11 PM:     publish: /opt/build/repo/public
5:20:11 PM:     publishOrigin: config

I should probably add my Netlify.toml here:

[build]
publish = "public"
command = "hugo --gc --minify"

[context.production.environment]
HUGO_VERSION = "0.103.0"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"

[context.split1]
command = "hugo --gc --minify --enableGitInfo"

[context.split1.environment]
HUGO_VERSION = "0.103.0"
HUGO_ENV = "production"

[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"

[context.deploy-preview.environment]
HUGO_VERSION = "0.103.0"

[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"

[context.branch-deploy.environment]
HUGO_VERSION = "0.103.0"

[context.next.environment]
HUGO_ENABLEGITINFO = "true"

# Redirects
[[redirects]]
  from = "/playpen/*"
  to = "/:splat"
  
[[redirects]]
  from = "/power-of-ten/*"
  to = "/podcasts/"
  
[[redirects]]
  from = "/coaching/*"
  to = "/teaching/coaching/design-leadership-coaching/"

[[redirects]]
  from = "/npmjs/*"
  to = "/npmjs/"
  status = 200
  
[[redirects]]
  from = "/mt/*"
  to = "/:splat"

[[redirects]]
  from = "/feed"
  to = "/index.xml"
  status = 200
  force = true

[[redirects]]
  from = "/feed/"
  to = "/index.xml"
  status = 200
  force = true

Hi @apolaine

Unfortunately you have not included the relevant section of the deploy log that contains the source/reason for the error. If you can update the deploy log over to include the error message, that would help.

Have a look at the Hugo suggestions in this support guide too

Hi @apolaine,

Your build log shows this error:

ERROR 2022/09/17 16:00:48 instagram shortcode: Missing config value for services.instagram.accessToken. This can be set in config.toml, but it is recommended to configure this via the HUGO_SERVICES_INSTAGRAM_ACCESSTOKEN OS environment variable. If you are using a Client Access Token, remember that you must combine it with your App ID using a pipe symbol (<APPID>|<CLIENTTOKEN>) otherwise the request will fail.

I think the error message is pretty verbose and explanatory, but let us know if you are still stuck.

Thanks, here is the full build log:

5:59:53 PM: Build ready to start
6:00:16 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
6:00:16 PM: build-image tag: v4.10.1
6:00:16 PM: buildbot version: 7e449fda4d95fa42451b88186ca7054116649237
6:00:16 PM: Fetching cached dependencies
6:00:16 PM: Failed to fetch cache, continuing with build
6:00:16 PM: Starting to prepare the repo for build
6:00:16 PM: No cached dependencies found. Cloning fresh repo
6:00:16 PM: git clone https://github.com/apolaine/playpen
6:00:27 PM: Preparing Git Reference refs/heads/master
6:00:29 PM: Parsing package.json dependencies
6:00:29 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify' versus 'hugo' in the Netlify UI
6:00:29 PM: Starting build script
6:00:29 PM: Installing dependencies
6:00:29 PM: Python version set to 2.7
6:00:30 PM: Downloading and installing node v10.24.1...
6:00:30 PM: Downloading https://nodejs.org/dist/v10.24.1/node-v10.24.1-linux-x64.tar.xz...
6:00:30 PM: Computing checksum with sha256sum
6:00:30 PM: Checksums matched!
6:00:31 PM: Now using node v10.24.1 (npm v6.14.12)
6:00:31 PM: Started restoring cached build plugins
6:00:31 PM: Finished restoring cached build plugins
6:00:31 PM: Attempting ruby version 2.6.2, read from environment
6:00:32 PM: Required ruby-2.6.2 is not installed - installing.
6:00:32 PM: Searching for binary rubies, this might take some time.
6:00:32 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.2.tar.bz2
6:00:32 PM: Checking requirements for ubuntu.
6:00:33 PM: Requirements installation successful.
6:00:33 PM: ruby-2.6.2 - #configure
6:00:33 PM: ruby-2.6.2 - #download
6:00:33 PM: ruby-2.6.2 - #validate archive
6:00:37 PM: ruby-2.6.2 - #extract
6:00:39 PM: ruby-2.6.2 - #validate binary
6:00:39 PM: ruby-2.6.2 - #setup
6:00:39 PM: ruby-2.6.2 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.6.2@global
6:00:40 PM: ruby-2.6.2 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
6:00:40 PM: ruby-2.6.2 - #generating global wrappers........
6:00:40 PM: ruby-2.6.2 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.6.2
6:00:40 PM: ruby-2.6.2 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
6:00:40 PM: ruby-2.6.2 - #generating default wrappers........
6:00:41 PM: Using /opt/buildhome/.rvm/gems/ruby-2.6.2
6:00:41 PM: Using ruby version 2.6.2
6:00:41 PM: Using PHP version 8.0
6:00:41 PM: Installing Hugo 0.103.0
6:00:42 PM: hugo v0.103.0-beebf2afb09a7be36cf12bdec8a99ae9286504e2+extended linux/amd64 BuildDate=2022-09-15T16:23:56Z VendorInfo=gohugoio
6:00:42 PM: Started restoring cached go cache
6:00:42 PM: Finished restoring cached go cache
6:00:42 PM: Installing Go version 1.12 (requested 1.12)
6:00:46 PM: unset GOOS;
6:00:46 PM: unset GOARCH;
6:00:46 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
6:00:46 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
6:00:46 PM: go version >&2;
6:00:46 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.12.linux.amd64.env"
6:00:46 PM: go version go1.12 linux/amd64
6:00:46 PM: Installing missing commands
6:00:46 PM: Verify run directory
6:00:47 PM: ​
6:00:47 PM: ────────────────────────────────────────────────────────────────
6:00:47 PM:   Netlify Build                                                 
6:00:47 PM: ────────────────────────────────────────────────────────────────
6:00:47 PM: ​
6:00:47 PM: ❯ Version
6:00:47 PM:   @netlify/build 27.18.1
6:00:47 PM: ​
6:00:47 PM: ❯ Flags
6:00:47 PM:   baseRelDir: false
6:00:47 PM:   buildId: 6325eef99eada360b80d84ab
6:00:47 PM:   deployId: 6325eef9341225000834a97a
6:00:47 PM: ​
6:00:47 PM: ❯ Current directory
6:00:47 PM:   /opt/build/repo
6:00:47 PM: ​
6:00:47 PM: ❯ Config file
6:00:47 PM:   /opt/build/repo/netlify.toml
6:00:47 PM: ​
6:00:47 PM: ❯ Context
6:00:47 PM:   production
6:00:47 PM: ​
6:00:47 PM: ────────────────────────────────────────────────────────────────
6:00:47 PM:   1. build.command from netlify.toml                            
6:00:47 PM: ────────────────────────────────────────────────────────────────
6:00:47 PM: ​
6:00:47 PM: $ hugo --gc --minify
6:00:47 PM: Start building sites …
6:00:47 PM: hugo v0.103.0-beebf2afb09a7be36cf12bdec8a99ae9286504e2+extended linux/amd64 BuildDate=2022-09-15T16:23:56Z VendorInfo=gohugoio
6:00:47 PM: WARN 2022/09/17 16:00:47 The "twitter" shortcode will soon require two named parameters: user and id. See "/opt/build/repo/content/blog/2019-09-06-design-in-the-age-of-synthetic-realities.md:204:1"
6:00:48 PM: ERROR 2022/09/17 16:00:48 instagram shortcode: Missing config value for services.instagram.accessToken. This can be set in config.toml, but it is recommended to configure this via the HUGO_SERVICES_INSTAGRAM_ACCESSTOKEN OS environment variable. If you are using a Client Access Token, remember that you must combine it with your App ID using a pipe symbol (<APPID>|<CLIENTTOKEN>) otherwise the request will fail.
6:00:48 PM: If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
6:00:48 PM: ignoreErrors = ["error-missing-instagram-accesstoken"]
6:00:48 PM: WARN 2022/09/17 16:00:48 The "twitter" shortcode will soon require two named parameters: user and id. See "/opt/build/repo/content/blog/2019-09-06-design-in-the-age-of-synthetic-realities.md:295:1"
6:00:48 PM: WARN 2022/09/17 16:00:48 The "twitter" shortcode will soon require two named parameters: user and id. See "/opt/build/repo/content/blog/2019-09-06-design-in-the-age-of-synthetic-realities.md:422:1"
6:00:51 PM: Error: Error building site: logged 1 error(s)
6:00:51 PM: Total in 3923 ms
6:00:51 PM: ​
6:00:51 PM: ────────────────────────────────────────────────────────────────
6:00:51 PM:   "build.command" failed                                        
6:00:51 PM: ────────────────────────────────────────────────────────────────
6:00:51 PM: ​
6:00:51 PM:   Error message
6:00:51 PM:   Command failed with exit code 255: hugo --gc --minify (https://ntl.fyi/exit-code-255)
6:00:51 PM: ​
6:00:51 PM:   Error location
6:00:51 PM:   In build.command from netlify.toml:
6:00:51 PM:   hugo --gc --minify
6:00:51 PM: ​
6:00:51 PM:   Resolved config
6:00:51 PM:   build:
6:00:51 PM:     command: hugo --gc --minify
6:00:51 PM:     commandOrigin: config
6:00:51 PM:     environment:
6:00:51 PM:       - INCOMING_HOOK_BODY
6:00:51 PM:       - INCOMING_HOOK_TITLE
6:00:51 PM:       - INCOMING_HOOK_URL
6:00:51 PM:       - HUGO_VERSION
6:00:51 PM:       - HUGO_ENV
6:00:51 PM:       - HUGO_ENABLEGITINFO
6:00:51 PM:     publish: /opt/build/repo/public
6:00:51 PM:     publishOrigin: config
6:00:51 PM:   redirects:
6:00:51 PM:     - from: /playpen/*      to: /:splat    - from: /power-of-ten/*      to: /podcasts/    - from: /coaching/*      to: /teaching/coaching/design-leadership-coaching/    - from: /npmjs/*      status: 200      to: /npmjs/    - from: /mt/*      to: /:splat    - force: true      from: /feed      status: 200      to: /index.xml    - force: true      from: /feed/      status: 200      to: /index.xml  redirectsOrigin: configCaching artifacts
6:00:51 PM: Started saving build plugins
6:00:51 PM: Finished saving build plugins
6:00:51 PM: Started saving pip cache
6:00:51 PM: Finished saving pip cache
6:00:51 PM: Started saving emacs cask dependencies
6:00:51 PM: Finished saving emacs cask dependencies
6:00:51 PM: Started saving maven dependencies
6:00:51 PM: Finished saving maven dependencies
6:00:51 PM: Started saving boot dependencies
6:00:51 PM: Finished saving boot dependencies
6:00:51 PM: Started saving rust rustup cache
6:00:51 PM: Finished saving rust rustup cache
6:00:51 PM: Started saving go dependencies
6:00:51 PM: Finished saving go dependencies
6:00:52 PM: Cached ruby version 2.6.2
6:00:52 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:00:52 PM: Creating deploy upload records
6:00:52 PM: Failing build: Failed to build site
6:00:52 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
6:00:52 PM: Finished processing build request in 36.54131506s

Oh, so that error is the one, not the --gc --minify one the earlier build error shows?

Yes, that’s the actual error. The one you showed in the start is just stating that your build command failed. What I’ve shared is the reason.

1 Like

Thanks. That fixed it. It was indeed Meta breaking the web again with their Instagram API restrictions. The red build error I mentioned was what threw me. I’ll know to look a bit closer next time.

1 Like