Hugo w/ Dart Sass build Failed

  • Site name: bradbice
  • Site ID: e513803d-df71-4160-be46-f8f4077de48e

Build log:

4:17:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:17:45 PM: Netlify Build                                                 
4:17:45 PM: ────────────────────────────────────────────────────────────────
4:17:45 PM: ​
4:17:45 PM: ❯ Version
4:17:45 PM:   @netlify/build 29.15.1
4:17:45 PM: ​
4:17:45 PM: ❯ Flags
4:17:45 PM:   baseRelDir: false
4:17:45 PM:   buildId: 64a5cfd56742ae00086d64b0
4:17:45 PM:   deployId: 64a5cfd56742ae00086d64b2
4:17:45 PM: ​
4:17:45 PM: ❯ Current directory
4:17:45 PM:   /opt/build/repo
4:17:45 PM: ​
4:17:45 PM: ❯ Config file
4:17:45 PM:   /opt/build/repo/netlify.toml
4:17:45 PM: ​
4:17:45 PM: ❯ Context
4:17:45 PM:   production
4:17:45 PM: ​
4:17:45 PM: build.command from netlify.toml                               
4:17:45 PM: ────────────────────────────────────────────────────────────────
4:17:45 PM: ​
4:17:45 PM: $ curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify 
4:17:45 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
4:17:45 PM:                                  Dload  Upload   Total   Spent    Left  Speed
4:17:45 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:17:45 PM: 100     9  100     9    0     0     63      0 --:--:-- --:--:-- --:--:--    63
4:17:45 PM: tar: This does not look like a tar archive
4:17:45 PM: gzip: stdin: not in gzip format
4:17:45 PM: tar: Child returned status 1
4:17:45 PM: tar: Error is not recoverable: exiting now
4:17:45 PM: ​
4:17:45 PM: build.command failed                                        
4:17:45 PM: ────────────────────────────────────────────────────────────────
4:17:45 PM: ​
4:17:45 PM:   Error message
4:17:45 PM:   Command failed with exit code 2: curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify (https://ntl.fyi/exit-code-2)
4:17:45 PM: ​
4:17:45 PM:   Error location
4:17:45 PM:   In build.command from netlify.toml:
4:17:45 PM:   curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify
4:17:45 PM: ​
4:17:45 PM:   Resolved config
4:17:45 PM:   build:
4:17:45 PM:     command: 'curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify '
4:17:45 PM:     commandOrigin: config
4:17:45 PM:     environment:
4:17:45 PM:       - PUSHOVER_API_TOKEN
4:17:45 PM:       - PUSHOVER_USER_KEY
4:17:45 PM:       - TAGS
4:17:45 PM:     publish: /opt/build/repo/public
4:17:45 PM:     publishOrigin: config
4:17:46 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:17:46 PM: Failing build: Failed to build site
4:17:46 PM: Finished processing build request in 19.745s

Replacing ${DART_SASS_VERSION} with 1.63.6 results in a similar but different build error (looks like code errors though code runs fine on my machine and it appears to be installing an old version of Hugo, v0.85.0:

4:26:13 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:26:11 PM: Netlify Build                                                 
4:26:11 PM: ────────────────────────────────────────────────────────────────
4:26:11 PM: ​
4:26:11 PM: ❯ Version
4:26:11 PM:   @netlify/build 29.15.1
4:26:11 PM: ​
4:26:11 PM: ❯ Flags
4:26:11 PM:   baseRelDir: false
4:26:11 PM:   buildId: 64a5d1b1ad54c10008997854
4:26:11 PM:   deployId: 64a5d1b1ad54c10008997856
4:26:11 PM: ​
4:26:11 PM: ❯ Current directory
4:26:11 PM:   /opt/build/repo
4:26:11 PM: ​
4:26:11 PM: ❯ Config file
4:26:11 PM:   /opt/build/repo/netlify.toml
4:26:11 PM: ​
4:26:11 PM: ❯ Context
4:26:11 PM:   production
4:26:11 PM: ​
4:26:11 PM: build.command from netlify.toml                               
4:26:11 PM: ────────────────────────────────────────────────────────────────
4:26:11 PM: ​
4:26:11 PM: $ curl -LJO https://github.com/sass/dart-sass/releases/download/1.63.6/dart-sass-1.63.6-linux-x64.tar.gz && tar -xf dart-sass-1.63.6-linux-x64.tar.gz && rm dart-sass-1.63.6-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify 
4:26:11 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
4:26:11 PM:                                  Dload  Upload   Total   Spent    Left  Speed
4:26:11 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:26:11 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:26:11 PM: 100 3665k  100 3665k    0     0  14.3M      0 --:--:-- --:--:-- --:--:-- 14.3M
4:26:11 PM: curl: Saved to filename 'dart-sass-1.63.6-linux-x64.tar.gz'
4:26:11 PM: Start building sites …
4:26:11 PM: hugo v0.85.0-724D5DB5+extended linux/amd64 BuildDate=2021-07-05T10:46:28Z VendorInfo=gohugoio
4:26:12 PM: ERROR 2023/07/05 20:26:12 render of page failed: /opt/build/repo/layouts/colophon/single.html:2:23: execute of template failed: template: colophon/single.html:2:3: executing intro at <partial intro-default.html .>: error calling partial: execute of template failed: template: partials/intro-default.html:3:11: executing partials/intro-default.html at <partial breadcrumbs.html .>: error calling partial: /opt/build/repo/layouts/partials/breadcrumbs.html:2:23: execute of template failed: template: partials/breadcrumbs.html:2:23: executing partials/breadcrumbs.html at <.Ancestors.Reverse>: can't evaluate field Ancestors in type *hugolib.pageState
ERROR 2023/07/05 20:26:12 render of page failed: /opt/build/repo/layouts/contact/single.html:2:23: execute of template failed: template: contact/single.html:2:3: executing intro at <partial intro-default.html .>: error calling partial: execute of template failed: template: partials/intro-default.html:3:11: executing partials/intro-default.html at <partial breadcrumbs.html .>: error calling partial: /opt/build/repo/layouts/partials/breadcrumbs.html:2:23: execute of template failed: template: partials/breadcrumbs.html:2:23: executing partials/breadcrumbs.html at <.Ancestors.Reverse>: can't evaluate field Ancestors in type *hugolib.pageState
ERROR 2023/07/05 20:26:12 render of page failed: /opt/build/repo/layouts/breakdown-movies/single.html:2:23: execute of template failed: template: breakdown-movies/single.html:2:3: executing intro at <partial intro-default.html .>: error calling partial: execute of template failed: template: partials/intro-default.html:3:11: executing partials/intro-default.html at <partial breadcrumbs.html .>: error calling partial: /opt/build/repo/layouts/partials/breadcrumbs.html:2:23: execute of template failed: template: partials/breadcrumbs.html:2:23: executing partials/breadcrumbs.html at <.Ancestors.Reverse>: can't evaluate field Ancestors in type *hugolib.pageState
ERROR 2023/07/05 20:26:12 render of page failed: /opt/build/repo/layouts/text-list/single.html:2:23: execute of template failed: template: text-list/single.html:2:3: executing intro at <partial intro-default.html .>: error calling partial: execute of template failed: template: partials/intro-default.html:3:11: executing partials/intro-default.html at <partial breadcrumbs.html .>: error calling partial: /opt/build/repo/layouts/partials/breadcrumbs.html:2:23: execute of template failed: template: partials/breadcrumbs.html:2:23: executing partials/breadcrumbs.html at <.Ancestors.Reverse>: can't evaluate field Ancestors in type *hugolib.pageState
ERROR 2023/07/05 20:26:12 TOCSS-DART: failed to transform scss/bradbice.scss (text/x-scss). You need dart-sass-embedded in your system $PATH.
4:26:12 PM: Error: Error building site: failed to render pages: render of page failed: /opt/build/repo/layouts/_default/single.html:2:23: execute of template failed: template: _default/single.html:2:3: executing intro at <partial intro-default.html .>: error calling partial: execute of template failed: template: partials/intro-default.html:3:11: executing partials/intro-default.html at <partial breadcrumbs.html .>: error calling partial: /opt/build/repo/layouts/partials/breadcrumbs.html:2:23: execute of template failed: template: partials/breadcrumbs.html:2:23: executing partials/breadcrumbs.html at <.Ancestors.Reverse>: can't evaluate field Ancestors in type *hugolib.pageState
Total in 922 ms
4:26:12 PM: ​
4:26:12 PM: build.command failed                                        
4:26:12 PM: ────────────────────────────────────────────────────────────────
4:26:12 PM: ​
4:26:12 PM:   Error message
4:26:12 PM:   Command failed with exit code 255: curl -LJO https://github.com/sass/dart-sass/releases/download/1.63.6/dart-sass-1.63.6-linux-x64.tar.gz && tar -xf dart-sass-1.63.6-linux-x64.tar.gz && rm dart-sass-1.63.6-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify (https://ntl.fyi/exit-code-255)
4:26:12 PM: ​
4:26:12 PM:   Error location
4:26:12 PM:   In build.command from netlify.toml:
4:26:12 PM:   curl -LJO https://github.com/sass/dart-sass/releases/download/1.63.6/dart-sass-1.63.6-linux-x64.tar.gz && tar -xf dart-sass-1.63.6-linux-x64.tar.gz && rm dart-sass-1.63.6-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify
4:26:12 PM: ​
4:26:12 PM:   Resolved config
4:26:12 PM:   build:
4:26:12 PM:     command: 'curl -LJO https://github.com/sass/dart-sass/releases/download/1.63.6/dart-sass-1.63.6-linux-x64.tar.gz && tar -xf dart-sass-1.63.6-linux-x64.tar.gz && rm dart-sass-1.63.6-linux-x64.tar.gz && export PATH=/opt/build/repo/dart-sass:$PATH && hugo --gc --minify '
4:26:12 PM:     commandOrigin: config
4:26:12 PM:     environment:
4:26:12 PM:       - PUSHOVER_API_TOKEN
4:26:12 PM:       - PUSHOVER_USER_KEY
4:26:12 PM:       - TAGS
4:26:12 PM:     publish: /opt/build/repo/public
4:26:12 PM:     publishOrigin: config
4:26:13 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:26:13 PM: Failing build: Failed to build site
4:26:14 PM: Finished processing build request in 20.647s

I’m including a netlify.toml file and no build.sh file. Deploy settings attached.

Hugo 0.85.0 is the default. You need to specify the version if you wish to use a different one: Hugo on Netlify | Netlify Docs

Thank you. Now that dart-sass-embedded is no longer needed, I removed the build.sh which was also setting up the Hugo version. Adding the Environment variable worked.

that’s awesome! Glad to hear it.