"build.command" failed with exit code 255 although the local building is successful

Netlify site name: https://www.legostay.com/

Build problems:
FULL build log:

1:57:31 PM: build-image version: 1ca34a93198b041e44214013884c57d146a23fed (focal)
1:57:31 PM: build-image tag: v4.16.4
1:57:31 PM: buildbot version: 5d70ebdb976733297fb4c90b41002389a248e2df
1:57:31 PM: Building without cache
1:57:31 PM: Starting to prepare the repo for build
1:57:32 PM: No cached dependencies found. Cloning fresh repo
1:57:32 PM: git clone --filter=blob:none https://github.com/Ksyula/personal_website
1:57:32 PM: Preparing Git Reference refs/heads/master
1:57:35 PM: Parsing package.json dependencies
1:57:35 PM: Starting build script
1:57:36 PM: Installing dependencies
1:57:36 PM: Python version set to 2.7
1:57:36 PM: Downloading and installing node v12.18.0...
1:57:36 PM: Downloading https://nodejs.org/dist/v12.18.0/node-v12.18.0-linux-x64.tar.xz...
1:57:36 PM: Computing checksum with sha256sum
1:57:36 PM: Checksums matched!
1:57:37 PM: Now using node v12.18.0 (npm v6.14.4)
1:57:37 PM: Started restoring cached build plugins
1:57:37 PM: Finished restoring cached build plugins
1:57:38 PM: Attempting Ruby version 2.7.2, read from environment
1:57:38 PM: Using Ruby version 2.7.2
1:57:38 PM: Using PHP version 8.0
1:57:38 PM: Installing Hugo 0.84.3
1:57:39 PM: hugo v0.84.3-A1B0353C+extended linux/amd64 BuildDate=2021-06-29T11:40:22Z VendorInfo=gohugoio
1:57:39 PM: Started restoring cached go cache
1:57:39 PM: Finished restoring cached go cache
1:57:39 PM: Installing Go version 1.14.4 (requested 1.14.4)
1:57:43 PM: unset GOOS;
1:57:43 PM: unset GOARCH;
1:57:43 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.14.4.linux.amd64';
1:57:43 PM: export PATH="/opt/buildhome/.gimme/versions/go1.14.4.linux.amd64/bin:${PATH}";
1:57:43 PM: go version >&2;
1:57:43 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.14.4.linux.amd64.env"
1:57:43 PM: go version go1.14.4 linux/amd64
1:57:43 PM: Detected 1 framework(s)
1:57:43 PM: "hugo" at version "unknown"
1:57:43 PM: Installing missing commands
1:57:43 PM: Verify run directory
1:57:43 PM: Section completed: initializing
1:57:45 PM: ​
1:57:45 PM:   Netlify Build                                                 
1:57:45 PM: ────────────────────────────────────────────────────────────────
1:57:45 PM: ​
1:57:45 PM: ❯ Version
1:57:45 PM:   @netlify/build 29.5.1
1:57:45 PM: ​
1:57:45 PM: ❯ Flags
1:57:45 PM:   baseRelDir: true
1:57:45 PM:   buildId: 63d7beba165a3c15fd0ac5de
1:57:45 PM:   deployId: 63d7beba165a3c15fd0ac5e0
1:57:45 PM: ​
1:57:45 PM: ❯ Current directory
1:57:45 PM:   /opt/build/repo
1:57:45 PM: ​
1:57:45 PM: ❯ Config file
1:57:45 PM:   /opt/build/repo/netlify.toml
1:57:45 PM: ​
1:57:45 PM: ❯ Context
1:57:45 PM:   production
1:57:45 PM: ​
1:57:45 PM:   1. build.command from netlify.toml                            
1:57:45 PM: ────────────────────────────────────────────────────────────────
1:57:45 PM: ​
1:57:45 PM: $ hugo --gc --minify
1:57:45 PM: Start building sites …
1:57:45 PM: hugo v0.84.3-A1B0353C+extended linux/amd64 BuildDate=2021-06-29T11:40:22Z VendorInfo=gohugoio
1:57:45 PM: Total in 76 ms
1:57:45 PM: Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:49:8: executing "index.html" at <partial "sections/home.html" .>: error calling partial: "/opt/build/repo/themes/toha/layouts/partials/sections/home.html:43:16": execute of template failed: template: partials/sections/home.html:43:16: executing "partials/sections/home.html" at <$src.Resize>: nil pointer evaluating resource.Resource.Resize
1:57:45 PM: ​
1:57:45 PM:   "build.command" failed                                        
1:57:45 PM: ────────────────────────────────────────────────────────────────
1:57:45 PM: ​
1:57:45 PM:   Error message
1:57:45 PM:   Command failed with exit code 255: hugo --gc --minify (https://ntl.fyi/exit-code-255)
1:57:45 PM: ​
1:57:45 PM:   Error location
1:57:45 PM:   In build.command from netlify.toml:
1:57:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:57:45 PM:   hugo --gc --minify
1:57:45 PM: ​
1:57:45 PM:   Resolved config
1:57:45 PM:   build:
1:57:45 PM:     command: hugo --gc --minify
1:57:45 PM:     commandOrigin: config
1:57:45 PM:     environment:
1:57:45 PM:       - HUGO_ENABLEGITINFO
1:57:45 PM:       - HUGO_ENV
1:57:45 PM:       - HUGO_THEME
1:57:45 PM:       - HUGO_VERSION
1:57:45 PM:     publish: /opt/build/repo/public
1:57:45 PM:     publishOrigin: config
1:57:45 PM:   functionsDirectory: /opt/build/repo/netlify/functions
1:57:45 PM: Caching artifacts
1:57:45 PM: Started saving build plugins
1:57:45 PM: Finished saving build plugins
1:57:45 PM: Started saving pip cache
1:57:45 PM: Finished saving pip cache
1:57:45 PM: Started saving emacs cask dependencies
1:57:45 PM: Finished saving emacs cask dependencies
1:57:45 PM: Started saving maven dependencies
1:57:45 PM: Finished saving maven dependencies
1:57:45 PM: Started saving boot dependencies
1:57:45 PM: Finished saving boot dependencies
1:57:45 PM: Started saving rust rustup cache
1:57:45 PM: Finished saving rust rustup cache
1:57:45 PM: Started saving go dependencies
1:57:45 PM: Finished saving go dependencies
1:57:46 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:57:46 PM: Failing build: Failed to build site
1:57:46 PM: Finished processing build request in 14.782s

build settings screenshot:
Screen Shot 2023-01-30 at 14.08.26

github repo: GitHub - Ksyula/personal_website

the local build succeeds via hugo --gc --minify
I can run hugo server --theme toha --watch locally and open updated website on localhost.

@Ksyu_l The crux of the error appears to be:

1:57:45 PM: Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:49:8: executing "index.html" at <partial "sections/home.html" .>: error calling partial: "/opt/build/repo/themes/toha/layouts/partials/sections/home.html:43:16": execute of template failed: template: partials/sections/home.html:43:16: executing "partials/sections/home.html" at <$src.Resize>: nil pointer evaluating resource.Resource.Resize

Have you looked at other threads that reference exit-code-255?

Hello nathanmartin, yes, I have read some threads about exit-code-255: some of them referred to HUGO template building errors (which I also had and fixed), so I checked that the site is built locally. So I excluded the template errors before deploying, but the error from logs of the failed build tells failed to render pages: render of "home" failed.

I might have overlooked a similar thread that suggests the right solution under my conditions. Will greatly appreciate if you point me to the right one.

Unfortunately I can’t point you to a specific solution as I don’t use Hugo, so I’ve never hit that error.

I was just making sure you had seen the existing answers in case you could self-solve quickly.

Netlify’s support will have a better idea than I do!

Thanks nathanmartin.
It seems that I found the root cause of the problem described here: Nil pointer evaluating resource.Resource.Resize since version 0.57.0 Β· Issue #6442 Β· gohugoio/hugo Β· GitHub

It happens because of Hugo’s version and this problem didn’t occur before version 0.57.0. Apparently, I run the old Hugo version locally and use Hugo 0.84.3 in my netlify.toml, that is why I can build the site locally but not remotely.

2 Likes

Hi @Ksyu_l :wave:t6:,

Thanks so much for coming back and providing your solution.