Hugo Build Failing After Upgrading Theme Submodule

Howdy Netlifyers,

I’ve done something dumb, and I can’t figure out what.

In short, I “upgraded” the theme in my previously working Hugo project by removing the submodule and and re-adding it.

Full disclosure: First I tried the following, and then removed and re-added.

git submodule update --rebase --remote

Also (not sure if this is a factor or not) I upgraded to Hugo v 0.58.0 extended build, upgrading the netlify.toml file to that version number everywhere.

I followed these instructions (Host on Netlify | Hugo) to (re)add the submodule.

The build fails with the below (after pushing to connected Github repo).

Any pointers in the right direction would be much appreciated.

4:33:14 PM: Build ready to start
4:33:16 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
4:33:16 PM: build-image tag: v3.3.2
4:33:16 PM: buildbot version: c78d626072f493c5e920f1da6e930a88f3a7d230
4:33:16 PM: Fetching cached dependencies
4:33:16 PM: Starting to download cache of 255.0KB
4:33:16 PM: Finished downloading cache in 94.698982ms
4:33:16 PM: Starting to extract cache
4:33:16 PM: Failed to fetch cache, continuing with build
4:33:16 PM: Starting to prepare the repo for build
4:33:17 PM: No cached dependencies found. Cloning fresh repo
4:33:17 PM: git clone https://github.com/kimfucious/techsarcana
4:33:17 PM: Preparing Git Reference refs/heads/master
4:33:19 PM: Error checking out submodules: Submodule 'themes/hermit' (https://github.com/Track3/hermit.git) registered for path 'themes/hermit'
Cloning into '/opt/build/repo/themes/hermit'...
error: Server does not allow request for unadvertised object 76715f1035b6b41393b876482a6ee21a0eae5c13
Fetched in submodule path 'themes/hermit', but it did not contain 76715f1035b6b41393b876482a6ee21a0eae5c13. Direct fetching of that commit failed.
4:33:19 PM: Failing build: Failed to prepare repo
4:33:19 PM: failed during stage 'preparing repo': Error checking out submodules: Submodule 'themes/hermit' (https://github.com/Track3/hermit.git) registered for path 'themes/hermit'
Cloning into '/opt/build/repo/themes/hermit'...
error: Server does not allow request for unadvertised object 76715f1035b6b41393b876482a6ee21a0eae5c13
Fetched in submodule path 'themes/hermit', but it did not contain 76715f1035b6b41393b876482a6ee21a0eae5c13. Direct fetching of that commit failed.
: exit status 1

Okay, I made some progress on this.

I removed the submodule again and I deleted .git/modules/themes/.

The deploy failed, so I did a retry deploy, using clear cache and deploy.

:tada: No more module errors, but I’m failing for another reason:

5:13:34 PM: Error: failed to prune cache "assets": remove /opt/build/repo/resources/_gen/assets/js/js/bundle.js_d11fe7b62c27961c87ecd0f2490357b9.content: no such file or directory
5:13:34 PM: Skipping functions preparation step: no functions directory set
5:13:34 PM: Caching artifacts
5:13:34 PM: Started saving pip cache
5:13:34 PM: Finished saving pip cache
5:13:34 PM: Started saving emacs cask dependencies
5:13:34 PM: Finished saving emacs cask dependencies
5:13:34 PM: Started saving maven dependencies
5:13:34 PM: Finished saving maven dependencies
5:13:34 PM: Started saving boot dependencies
5:13:34 PM: Finished saving boot dependencies
5:13:34 PM: Started saving go dependencies
5:13:34 PM: Finished saving go dependencies
5:13:39 PM: Error running command: Build script returned non-zero exit code: 255
5:13:39 PM: Failing build: Failed to build site
5:13:39 PM: failed during stage 'building site': Build script returned non-zero exit code: 255
5:13:39 PM: Finished processing build request in 16.713082918s

I’m thinking this is theme related now, nothing to do with Netlify.

That said, any help would be appreciated. Thanks.

Okay, I realize I’ve been talking to myself, but ya’know sometimes that helps.

I’m obviously not getting something here.

What I’ve discovered is that if I manually copy the files below into the resources/_gen/js/js directory, I can run hugo --gc --minify exactly once, and then they disappear.

bundle.js_d11fe7b62c27961c87ecd0f2490357b9.content
bundle.js_d11fe7b62c27961c87ecd0f2490357b9.json

Okay, talking to myself again…

I can get this to build if I use: hugo --minify, omitting the --gc

Not sure if this is best practice. Anyone got milk?

1 Like

Hi @Kimfucious, it isn’t necessary to do the cleanup after the build since the container is “reset” after your build is over. The only cache that’s carried between builds are files specifically copied in to our cache directory, and dependencies like node_modules and gems.

1 Like

Hey @futuregerald.

Thanks for the tip. I believe that removing --gc has solved my issues.

Not sure where I go the idea to do that. I think it may have been an old post I read.

We’re all good here!

1 Like

You’re welcome and thanks for sharing your solution here so others can find it :smile: