Netlify Build Error 255 (ToCSS) troubleshooting

Is your Hugo site not deploying on Netlify due to “Error 255”?

First make sure you’re using the new image build selection and try setting the HUGO_VERSION to the one you’re using locally. Info from Netlify docs. Generally this should work (see the many posts in this forum).

Still not working? It could be because Netlify isn’t using the Hugo Extended version.

However, if it’s not working and you’re getting errors that say “Command failed with exit code 255:” or “resource X not found in file cache” there’s a simple solution.

Error you’re probably seeing (note how the log says hugo’s not found and it installs a non-extended version)

4:35:55 PM: $ hugo --gc --minify --enableGitInfo --baseURL $URL --environment development
4:35:55 PM: DEBUG target={ platform: 'linux', arch: 'x64' }, hugo={ version: '0.71.0' }
4:35:55 PM: DEBUG searching executable at </opt/build/repo/node_modules/hugo-cli/tmp/hugo_0.71.0_linux_amd64>
4:35:55 PM: INFO hugo not found. Attempting to fetch it...
4:35:55 PM: DEBUG downloading archive from <https://github.com/gohugoio/hugo/releases/download/v0.71.0/hugo_0.71.0_Linux-64bit.tar.gz>
4:35:56 PM: INFO fetched hugo 0.71.0
4:35:56 PM: INFO extracting archive...
4:35:57 PM: DEBUG extracted archive to </opt/build/repo/node_modules/hugo-cli/tmp>
4:35:57 PM: INFO hugo available, let's go!
4:35:57 PM: Building sites …
4:37:57 PM: ERROR 2020/05/27 23:37:57 TOCSS: failed to transform "scss/main.scss" (text/x-scss): resource "scss/scss/main.scss_df0fcb6fcf7ac0465cc4f11d40f9fe96" not found in file cache
4:37:57 PM: Total in 120386 ms
4:37:57 PM: Error: Error building site: TOCSS: failed to transform "scss/main.scss" (text/x-scss): resource "scss/scss/main.scss_e59e0ecc24dedce3dd5dba3ad899859c" not found in file cache

What’s happening
For some reason Netlify build isn’t using Hugo’s extended version which you need to use SCSS/ToCSS.

How to fix
Add the hugo-extended package with npm install hugo-extended --save-dev

1 Like

So, the error message isn’t very helpful, I take the blame for that.

But you nee the extended version for this, and reading

You probably have an older Netlify build image set up.

@bep Thank you for the suggestion. Don’t be so hard on yourself, the improved error messages, especially 0.50, have been a massive help for me. Thanks!

In this instance it was an issue despite the correct build image where Netlify was using the non-extended version.

I’ve clarified my post to try your/netlify’s recommend troubleshooting first.

OK, but the only reason I know of why Netlify would use the non-extended version if you use an old build image, so I would double-and-triple check that. And if that fails, I would ask Netlify about it.

OK, looking closer …

DEBUG searching executable at </Users/computer/Code/jbm-marketing-site/node_modules/hugo-cli/tmp/hugo_0.71.1_darwin_amd64>
INFO hugo not found. Attempting to fetch it...
DEBUG downloading archive from <https://github.com/gohugoio/hugo/releases/download/v0.71.1/hugo_0.71.1_macOS-64bit.tar.gz>
INFO fetched hugo 0.71.1

The above log confuses me. Is this you running the netlify dev tool locally? Re. the refs to Darwin/MacOS. I have no idea how that work in all of this, though …

Reached out to Netlify first. They were the ones that pointed out that their build tool was using the non-extended version.

We confirmed that the right build image was being used:

That was a log from my local debugging efforts. I’ve updated the excerpt with Netlify’s build log.

I appreciate your efforts, Netlify seemed confused as to why it was using hugo non-extended.

If you are really curious in seeing the full deploy logs. I tried to record mostly the same commit so I could rule out any changes made to the repo. I’m not worried since it’s working now. I wrote the post as I think the fix was adding the npm package and it took me forever to come up with it since everything out there says change the build image which defaults to the correct one.

  1. last successful deploy before issue commit - staging@a28617b
  2. failed deploy of the exact commit same commit - staging@a28617b failing after the issue started - (no changes made to repo or netlify on my side but uses 0.71.0. Which makes no sense to me sense netlify.toml in that commit was for 0.71.1 as shown in the first build. Why wouldn’t it use what’s in netlify.toml??)
  3. first failed deploy - commit staging@dbc308a
  4. working deploy of the same commit staging@a28617b after a deploy cached the hugo-extended package was on netlify

Do you think it’s worth adding a proposal issue for an error message when Hugo extended is required but not present?

1 Like

Sorry for the late follow up here but commented on the relevant issue under the Netlify organisation https://github.com/netlify/build/issues/1392#issuecomment-640246741

TLDR: looks like there is a 3rd party dependency called hugo-cli shadowing Netlify build Hugo binary. Netlify does download the extended version, but hugo-cli doesn’t.

Solution - remove that dependency or use one that downloads the extended like hugo-extended.

1 Like

Solution - remove hugo-cli dependency or use hugo-extended

Thank you Erezrokah!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.