Netlify build fails with "Build script returned non-zero exit code: 255" after trivial commit

Hi all,
I noticed recently that my Netlify-hosted site was not building anymore.
This is my GH repo.

The latest working build occurred before this commit, in which I commented a few lines, but in the wrong way. I immediately noticed the syntax error I made and fixed the commit with this:

Even with the part commented out (heck, even with it removed!) it does not build anymore.

is the last working build log, and here:
is the next one, which failed.

What’s wrong? Has something changed in Netlify? I noticed the NODE version changed, but forcing the build with the old version in netlify.toml had no impact.

Thanks in advance for your help!

2:23:05 PM: Error: Unable to find theme Directory: /opt/build/repo/themes/academic

It seems to me the theme can’t be found. How are you making sure the (external) theme is there at build time? You made some changes to the .gitmodules file, maybe that’s the culprit. Go on an error hunt and checkout your site locally in a new folder to make sure it still builds outside of netlify.

1 Like

Also: did you try to just rebuild without the cached build-environment? The latest broken deploy has this option in a dropdown. It might be as simple as that.

There is a mismatch between your theme location and where Hugo looks for it (the default location). I assume that you somehow set the HUGO_THEMESDIR or run with the --themesDir flag set back when it was working …

Thank you all for your replies

I agree that this is probably a theme error. I never managed the theme in use (Academic). I can’t for the life of me understand why Hugo was previously looking for it in ./themes and now instead uses /opt/build/repo/themes/

The build succeeds locally with no error.

I now tried readding the .gitmodules and the academic.Rproj files, but it still does not work.

Yeah I did try that to no avail, unfortunately.

I never ever did anything regarding the theme (academic), I just cloned the academic repo. It might be that I changed something without knowing it, but not in the last (harmless) commit before it broke… then when?

I now tried adding the theme/academic folder to git. This was not necessary before.
Once this was done, the compilation goes a bit further, but still fails:

Apparently the 0.53 version of hugo was discontinued for this theme. 0.55 and 0.56 do not exist, because hugo switched to semantic versioning, so e.g. 0.56.0 in netlify.toml works.

I think what did it was reinitialise the submodule with git submodule update --init --recursive then set a new version in netlify.toml.

Thank you all!