Site won't deploy, Error checking out submodules

netifly site name: darling-llama-8e9ad8 (dryfly.ca)

I’ve built and updated my Hugo site a few times. I’m using the mainroad theme. I haven’t updated the site for a while and I may have forgotten to do something correctly. I added a new post (a new md file). I ran hugo server and everything looked good on my local computer. I deleted the public folder and ran hugo. I then did git commit -a -m "my update". Finally git push origin main. This triggered the build on Netlify. My deploy log is:

1:21:36 PM: Build ready to start

1:21:42 PM: build-image version: a13ca271c42226d886b5d1dc0da3d70cb6ac0627 (focal)

1:21:42 PM: build-image tag: v4.11.0

1:21:42 PM: buildbot version: 28ac1cc020586b1ec2af1c1e9bb64025ce31310b

1:21:42 PM: Fetching cached dependencies

1:21:42 PM: Failed to fetch cache, continuing with build

1:21:42 PM: Starting to prepare the repo for build

1:21:42 PM: No cached dependencies found. Cloning fresh repo

1:21:42 PM: git clone https://github.com/shmish/dryfly

1:21:44 PM: Preparing Git Reference refs/heads/main

1:21:45 PM: Error checking out submodules: Submodule 'themes/mainroad' (https://github.com/vimux/mainroad.git) registered for path 'themes/mainroad'
Cloning into '/opt/build/repo/themes/mainroad'...
fatal: remote error: upload-pack: not our ref 1b0de5f2ede934f02f0dde112cfd29a704d7faee
fatal: Fetched in submodule path 'themes/mainroad', but it did not contain 1b0de5f2ede934f02f0dde112cfd29a704d7faee. Direct fetching of that commit failed.

1:21:45 PM: Creating deploy upload records

1:21:45 PM: Failing build: Failed to prepare repo

1:21:45 PM: Failed during stage 'preparing repo': Error checking out submodules: Submodule 'themes/mainroad' (https://github.com/vimux/mainroad.git) registered for path 'themes/mainroad'
Cloning into '/opt/build/repo/themes/mainroad'...
fatal: remote error: upload-pack: not our ref 1b0de5f2ede934f02f0dde112cfd29a704d7faee
fatal: Fetched in submodule path 'themes/mainroad', but it did not contain 1b0de5f2ede934f02f0dde112cfd29a704d7faee. Direct fetching of that commit failed.
: exit status 128

1:21:45 PM: Finished processing build request in 3.049364688s

Something that I might have messed up is the following. I was making the changes in vscode. I noticed that the git tab collated something like 2k modified files. I then noticed that vscode said I was in “master” branch. I think this is referring to a submodule. I try to checkout “main” in vscode and it keeps saying that I’m in branch “master”. I don’t quite understand this. In my terminal git status confirms that I am in the main branch.

Hi @shmish

The issue here is that the commit reference used for the submodule isn’t valid. It is nothing do to with your repository per se.

I couldn’t figure out how to solve this submodule error so I decided to get rid of mainroad as submodule. removed mainroad from the .gitmodule file and ran git rm --cached themes/mainroad. I deleted public folder, ran hugo sever and hugo on my local machine and the site worked, I’m not aware of any errors. I then pushed these changes to github. This deploy fails with:

6:45:08 AM: Build ready to start
6:45:09 AM: build-image version: a13ca271c42226d886b5d1dc0da3d70cb6ac0627 (focal)
6:45:09 AM: build-image tag: v4.11.0
6:45:09 AM: buildbot version: 28ac1cc020586b1ec2af1c1e9bb64025ce31310b
6:45:09 AM: Fetching cached dependencies
6:45:09 AM: Failed to fetch cache, continuing with build
6:45:09 AM: Starting to prepare the repo for build
6:45:10 AM: No cached dependencies found. Cloning fresh repo
6:45:10 AM: git clone https://github.com/shmish/dryfly
6:45:11 AM: Preparing Git Reference refs/heads/main
6:45:12 AM: Parsing package.json dependencies
6:45:13 AM: Starting build script
6:45:13 AM: Installing dependencies
6:45:13 AM: Python version set to 2.7
6:45:13 AM: v16.17.1 is already installed.
6:45:14 AM: Now using node v16.17.1 (npm v8.15.0)
6:45:14 AM: Started restoring cached build plugins
6:45:14 AM: Finished restoring cached build plugins
6:45:14 AM: Attempting ruby version 2.7.2, read from environment
6:45:14 AM: Using ruby version 2.7.2
6:45:15 AM: Using PHP version 8.0
6:45:15 AM: Installing Hugo 0.101.0
6:45:15 AM: hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio
6:45:15 AM: Started restoring cached go cache
6:45:15 AM: Finished restoring cached go cache
6:45:15 AM: Installing Go version 1.17 (requested 1.17)
6:45:19 AM: unset GOOS;
6:45:19 AM: unset GOARCH;
6:45:19 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
6:45:19 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
6:45:19 AM: go version >&2;
6:45:19 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
6:45:19 AM: go version go1.17 linux/amd64
6:45:19 AM: Installing missing commands
6:45:19 AM: Verify run directory
6:45:21 AM: ​
6:45:21 AM: ────────────────────────────────────────────────────────────────
6:45:21 AM:   Netlify Build                                                 
6:45:21 AM: ────────────────────────────────────────────────────────────────
6:45:21 AM: ​
6:45:21 AM: ❯ Version
6:45:21 AM:   @netlify/build 27.18.6
6:45:21 AM: ​
6:45:21 AM: ❯ Flags
6:45:21 AM:   baseRelDir: true
6:45:21 AM:   buildId: 6338446423fd170008db6b10
6:45:21 AM:   deployId: 6338446423fd170008db6b12
6:45:21 AM: ​
6:45:21 AM: ❯ Current directory
6:45:21 AM:   /opt/build/repo
6:45:21 AM: ​
6:45:21 AM: ❯ Config file
6:45:21 AM:   No config file was defined: using default values.
6:45:21 AM: ​
6:45:21 AM: ❯ Context
6:45:21 AM:   production
6:45:21 AM: ​
6:45:21 AM: ────────────────────────────────────────────────────────────────
6:45:21 AM:   1. Build command from Netlify app                             
6:45:21 AM: ────────────────────────────────────────────────────────────────
6:45:21 AM: ​
6:45:21 AM: $ hugo
6:45:21 AM: Error: module "mainroad" not found; either add it as a Hugo Module or store it in "/opt/build/repo/themes".: module does not exist
6:45:21 AM: Total in 0 ms
6:45:21 AM: ​
6:45:21 AM: ────────────────────────────────────────────────────────────────
6:45:21 AM:   "build.command" failed                                        
6:45:21 AM: ────────────────────────────────────────────────────────────────
6:45:21 AM: ​
6:45:21 AM:   Error message
6:45:21 AM:   Command failed with exit code 255: hugo (https://ntl.fyi/exit-code-255)
6:45:21 AM: ​
6:45:21 AM:   Error location
6:45:21 AM:   In Build command from Netlify app:
6:45:21 AM:   hugo
6:45:21 AM: ​
6:45:21 AM:   Resolved config
6:45:21 AM:   build:
6:45:21 AM:     command: hugo
6:45:21 AM:     commandOrigin: ui
6:45:21 AM:     environment:
6:45:21 AM:       - HUGO_VERSION
6:45:21 AM:     publish: /opt/build/repo/public
6:45:21 AM:     publishOrigin: ui
6:45:21 AM: Caching artifacts
6:45:21 AM: Started saving build plugins
6:45:21 AM: Finished saving build plugins
6:45:21 AM: Started saving pip cache
6:45:21 AM: Finished saving pip cache
6:45:21 AM: Started saving emacs cask dependencies
6:45:21 AM: Finished saving emacs cask dependencies
6:45:21 AM: Started saving maven dependencies
6:45:21 AM: Finished saving maven dependencies
6:45:21 AM: Started saving boot dependencies
6:45:21 AM: Finished saving boot dependencies
6:45:21 AM: Started saving rust rustup cache
6:45:21 AM: Finished saving rust rustup cache
6:45:21 AM: Started saving go dependencies
6:45:21 AM: Finished saving go dependencies
6:45:22 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:45:22 AM: Creating deploy upload records
6:45:22 AM: Failing build: Failed to build site
6:45:22 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
6:45:22 AM: Finished processing build request in 12.652474805s

I understand that when Netlify builds the hugo site, it thinks the mainroad module is missing. I don’t see this when I run it locally.

As the repository you are deploying from is private there is not a lot of assistance I can offer.

1 Like

Did you try doing as it says though? That is, copy the mainroad theme in your project’s theme folder?

Maybe you’ve done it locally, but that doesn’t exist on your Git repo which we clone?

I am getting the same error.
My repo link - GitHub - VedantSuryawanshi/tnotch

Hi vedant, glad you found us :wave:t6: before we can help you, we need a little more information on the issues you are facing.

First, have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console