Command failed with exit code 255: hugo --gc --minify

Hi, I am new to Hugo. When I try to depoly, it failed showing the following message:

Skip to main content

  1. Hugo Team
  2. stoic-volhard-8b127f

Upgrade

Deploy details

Deploy failed

Production: main@HEAD. Today at 1:27 AM

We couldn’t deploy your site. Check out our Build docs for tips on troubleshooting your build, or ask us for debugging advice.

Deploy settings

Fancy a game?

This deploy is done, but hey, you can still play if you want to!

Deploy log

1:27:04 AM: Build ready to start

1:27:06 AM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)

1:27:06 AM: build-image tag: v4.5.3

1:27:06 AM: buildbot version: 25fcfe2826afed3a7b9532f47a1782777298db51

1:27:06 AM: Fetching cached dependencies

1:27:06 AM: Failed to fetch cache, continuing with build

1:27:06 AM: Starting to prepare the repo for build

1:27:07 AM: No cached dependencies found. Cloning fresh repo

1:27:07 AM: git clone https://github.com/sardarms/test-site-1

1:27:07 AM: Preparing Git Reference refs/heads/main

1:27:07 AM: Parsing package.json dependencies

1:27:08 AM: Starting build script

1:27:08 AM: Installing dependencies

1:27:08 AM: Python version set to 2.7

1:27:09 AM: Downloading and installing node v16.14.0…

1:27:10 AM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz…

1:27:10 AM: Computing checksum with sha256sum

1:27:10 AM: Checksums matched!

1:27:14 AM: Now using node v16.14.0 (npm v8.3.1)

1:27:14 AM: Started restoring cached build plugins

1:27:14 AM: Finished restoring cached build plugins

1:27:14 AM: Attempting ruby version 2.7.2, read from environment

1:27:16 AM: Using ruby version 2.7.2

1:27:16 AM: Using PHP version 8.0

1:27:16 AM: Installing Hugo 0.92.2

1:27:18 AM: hugo v0.92.2-CDF6A0D6+extended linux/amd64 BuildDate=2022-02-11T14:17:39Z VendorInfo=gohugoio

1:27:18 AM: Started restoring cached go cache

1:27:18 AM: Finished restoring cached go cache

1:27:18 AM: go version go1.16.5 linux/amd64

1:27:18 AM: go version go1.16.5 linux/amd64

1:27:18 AM: Installing missing commands

1:27:18 AM: Verify run directory

1:27:20 AM: ​

1:27:20 AM: ────────────────────────────────────────────────────────────────

1:27:20 AM: Netlify Build

1:27:20 AM: ────────────────────────────────────────────────────────────────

1:27:20 AM: ​

1:27:20 AM: ❯ Version

1:27:20 AM: @netlify/build 26.3.2

1:27:20 AM: ​

1:27:20 AM: ❯ Flags

1:27:20 AM: baseRelDir: true

1:27:20 AM: buildId: 620aad0817c65066304d3375

1:27:20 AM: deployId: 620aad0817c65066304d3377

1:27:20 AM: ​

1:27:20 AM: ❯ Current directory

1:27:20 AM: /opt/build/repo

1:27:20 AM: ​

1:27:20 AM: ❯ Config file

1:27:20 AM: /opt/build/repo/netlify.toml

1:27:20 AM: ​

1:27:20 AM: ❯ Context

1:27:20 AM: production

1:27:20 AM: ​

1:27:20 AM: ────────────────────────────────────────────────────────────────

1:27:20 AM: 1. build.command from netlify.toml

1:27:20 AM: ────────────────────────────────────────────────────────────────

1:27:20 AM: ​

1:27:20 AM: $ hugo --gc --minify

1:27:20 AM: Start building sites …

1:27:20 AM: hugo v0.92.2-CDF6A0D6+extended linux/amd64 BuildDate=2022-02-11T14:17:39Z VendorInfo=gohugoio

1:27:20 AM: WARN 2022/02/14 19:27:20 The β€œtwitter_simple” shortcode will soon require two named parameters: user and id. See β€œ/opt/build/repo/content/blog/rich-content.md:24:1”

1:27:20 AM: ERROR 2022/02/14 19:27:20 JSON parse error: expected comma character or an array or object ending on line 87 and column 40

1:27:20 AM: 12: {

1:27:20 AM: ^

1:27:20 AM: ERROR 2022/02/14 19:27:20 JSON parse error: expected comma character or an array or object ending on line 87 and column 40

1:27:20 AM: 12: {

1:27:20 AM: ^

1:27:20 AM: ERROR 2022/02/14 19:27:20 JSON parse error: expected comma character or an array or object ending on line 87 and column 40

1:27:20 AM: 12: {

1:27:20 AM: ^

1:27:20 AM: ERROR 2022/02/14 19:27:20 JSON parse error: expected comma character or an array or object ending on line 87 and column 40

1:27:20 AM: 12: {

1:27:20 AM: ^

1:27:20 AM: Error: Error building site: failed to render pages: render of β€œpage” failed: execute of template failed: template: _default/single.html:5:8: executing β€œ_default/single.html” at <partial β€œhead.html” .>: error calling partial: execute of template failed: template: partials/templates/opengraph.html:45:17: executing β€œpartials/templates/opengraph.html” at <index $siteSeries ($name | urlize)>: error calling index: index of untyped nil

1:27:20 AM: Total in 474 ms

1:27:20 AM: ​

1:27:20 AM: ────────────────────────────────────────────────────────────────

1:27:20 AM: β€œbuild.command” failed

1:27:20 AM: ────────────────────────────────────────────────────────────────

1:27:20 AM: ​

1:27:20 AM: Error message

1:27:20 AM: Command failed with exit code 255: hugo --gc --minify

1:27:20 AM: ​

1:27:20 AM: Error location

1:27:20 AM: In build.command from netlify.toml:

1:27:20 AM: hugo --gc --minify

1:27:20 AM: ​

1:27:20 AM: Resolved config

1:27:20 AM: build:

1:27:20 AM: command: hugo --gc --minify

1:27:20 AM: commandOrigin: config

1:27:20 AM: environment:

1:27:20 AM: - HUGO_VERSION

1:27:20 AM: - HUGO_ENV

1:27:20 AM: - HUGO_ENABLEGITINFO

1:27:20 AM: publish: /opt/build/repo/public

1:27:20 AM: publishOrigin: config

1:27:20 AM: redirects:

1:27:21 AM: - from: /npmjs/*
status: 200
to: /npmjs/
redirectsOrigin: config
Caching artifacts

1:27:21 AM: Started saving build plugins

1:27:21 AM: Finished saving build plugins

1:27:21 AM: Started saving pip cache

1:27:21 AM: Finished saving pip cache

1:27:21 AM: Started saving emacs cask dependencies

1:27:21 AM: Finished saving emacs cask dependencies

1:27:21 AM: Started saving maven dependencies

1:27:21 AM: Finished saving maven dependencies

1:27:21 AM: Started saving boot dependencies

1:27:21 AM: Finished saving boot dependencies

1:27:21 AM: Started saving rust rustup cache

1:27:21 AM: Finished saving rust rustup cache

1:27:21 AM: Started saving go dependencies

1:27:21 AM: Finished saving go dependencies

1:27:24 AM: Build failed due to a user error: Build script returned non-zero exit code: 2

1:27:24 AM: Creating deploy upload records

1:27:24 AM: Failing build: Failed to build site

1:27:24 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2

1:27:24 AM: Finished processing build request in 17.82163704s

Β© 2022 Netlify

hi there, so, something is wrong here. not sure which json file it is (likely the package.json). Does this build locally?

i built it locally and it was fine. I first deploy it on cloudcannon, it works fine. Then I try netlify, it shows the error.

FYI, I deployed it on cloudlfare and it worked fine there too - https://test-site-1.pages.dev/.
Here are the cloudflare log -

08:05:33.763 Initializing build environment. This may take up to a few minutes to complete
08:07:36.347 Success: Finished initializing build environment
08:07:36.347 Cloning repository…
08:07:39.142 Success: Finished cloning repository files
08:07:40.181 Installing dependencies
08:07:40.183 Python version set to 2.7
08:07:41.049 v12.18.0 is already installed.
08:07:41.476 Now using node v12.18.0 (npm v6.14.4)
08:07:41.515 Started restoring cached build plugins
08:07:41.519 Finished restoring cached build plugins
08:07:41.635 Attempting ruby version 2.7.1, read from environment
08:07:42.562 Using ruby version 2.7.1
08:07:42.798 Using PHP version 5.6
08:07:42.827 5.2 is already installed.
08:07:42.836 Using Swift version 5.2
08:07:42.836 Installing Hugo 0.92.1
08:07:43.724 hugo v0.92.1-85E2E862+extended linux/amd64 BuildDate=2022-01-27T11:44:41Z VendorInfo=gohugoio
08:07:43.726 Started restoring cached go cache
08:07:43.729 Finished restoring cached go cache
08:07:43.753 go version go1.14.4 linux/amd64
08:07:43.757 go version go1.14.4 linux/amd64
08:07:43.758 Installing missing commands
08:07:43.758 Verify run directory
08:07:43.759 Executing user command: hugo
08:07:43.803 Start building sites …
08:07:43.803 hugo v0.92.1-85E2E862+extended linux/amd64 BuildDate=2022-01-27T11:44:41Z VendorInfo=gohugoio
08:07:43.851 WARN 2022/02/15 02:07:43 The twitter_simple shortcode will soon require two named parameters: user and id. See /opt/buildhome/repo/content/blog/rich-content.md:24:1
08:07:44.123
08:07:44.123
08:07:44.123 -------------------Β±----
08:07:44.123 Pages
08:07:44.123 Paginator pages
08:07:44.123 Non-page files
08:07:44.123 Static files
08:07:44.123 Processed images
08:07:44.123 Aliases
08:07:44.123 Sitemaps
08:07:44.123 Cleaned
08:07:44.123
08:07:44.123 Total in 344 ms
08:07:44.128 Finished
08:07:44.128 Note: No functions dir at /functions found. Skipping.
08:07:44.128 Validating asset output directory
08:07:45.575 Deploying your site to Cloudflare’s global network…
08:07:58.617 Success: Your site was deployed!

Hey @bondbipu,

This is a problem either with Hugo or the Theme, not with Netlify.

I tried your repo locally and got the exact same issue.

However:

The error only occurs with you run the command with --minify. For example, if you run just hugo, or hugo --gc, the build works. If you run hugo --minify, it doesn’t. This is probably why it’s working on Cloudflare as you’re not running --minify.

1 Like

@hrishikesh thank you for your response.

1 Like