Hugo build failing despite netlify having full bitbucket access (solved with moving to git submodules)

Hey!

I’ve been trying to get my deployment working now for about a full day. Running “netlify dev” works fine in local but after doing “netlify deploy”, the deployed code isn’t the latest and probably hence also has wrong URL for assets like CSS/JS. I used to have a BaseUrl-variable set but removed that for now.

So the issue currently is in the deployment. Netlify can’t for some weird reason download the Hugo-theme I’ve made. The theme lies in a private bitbucket repo and was well accessible when I used to have the theme as a git-submodule. I was suggested to move my things from submodules to hugo modules, which I’ve done, but now I’m facing this issue…

I’m not running latest Hugo since the JS compile has some issues when doing a upgrade from 0.77 to 0.79. I also thought about what if the usage of extended Hugo woudl be the problem, but that is aswell used as it can be seen in the log below.

As for access, I’ve generated a new public deploy key and put that into my account in bitbucket. I used to have it in the repos, but that gave only read-rights, this should give some more permissions.

Site name: vigorous-euler-1692f1

Build log:

5:12:58 PM: Build ready to start
5:13:00 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
5:13:00 PM: build-image tag: v3.6.0
5:13:00 PM: buildbot version: f66121aa8b7df3f09ef4ca9f2f1aa9cddabd6c71
5:13:00 PM: Building without cache
5:13:00 PM: Starting to prepare the repo for build
5:13:01 PM: No cached dependencies found. Cloning fresh repo
5:13:01 PM: git clone git@bitbucket.org:olligranlund/hugo-site
5:13:07 PM: Preparing Git Reference refs/heads/master
5:13:11 PM: Different build command detected, going to use the one specified in the Netlify configuration file: ‘hugo --gc --minify’ versus ‘hugo’ in the Netlify UI
5:13:11 PM: Starting build script
5:13:11 PM: Installing dependencies
5:13:11 PM: Python version set to 2.7
5:13:12 PM: Downloading and installing node v14.1.0…
5:13:12 PM: Downloading https://nodejs.org/dist/v14.1.0/node-v14.1.0-linux-x64.tar.xz
5:13:13 PM: Computing checksum with sha256sum
5:13:13 PM: Checksums matched!
5:13:16 PM: Now using node v14.1.0 (npm v6.14.4)
5:13:16 PM: Started restoring cached build plugins
5:13:16 PM: Finished restoring cached build plugins
5:13:16 PM: Attempting ruby version 2.7.1, read from environment
5:13:18 PM: Using ruby version 2.7.1
5:13:18 PM: Using PHP version 5.6
5:13:18 PM: Installing Hugo 0.77.0
5:13:19 PM: Hugo Static Site Generator v0.77.0-EF290125/extended linux/amd64 BuildDate: 2020-10-30T10:21:36Z
5:13:19 PM: Started restoring cached go cache
5:13:19 PM: Finished restoring cached go cache
5:13:19 PM: Installing Go version 1.15.2
5:13:24 PM: unset GOOS;
5:13:24 PM: unset GOARCH;
5:13:24 PM: export GOROOT=’/opt/buildhome/.gimme_cache/versions/go1.15.2.linux.amd64’;
5:13:24 PM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.15.2.linux.amd64/bin:{PATH}"; 5:13:24 PM: go version >&2; 5:13:24 PM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.15.2.linux.amd64.env" 5:13:24 PM: go version go1.15.2 linux/amd64 5:13:24 PM: Installing missing commands 5:13:24 PM: Verify run directory 5:13:26 PM: ​ 5:13:26 PM: ──────────────────────────────────────────────────────────────── 5:13:26 PM: Netlify Build 5:13:26 PM: ──────────────────────────────────────────────────────────────── 5:13:26 PM: ​ 5:13:26 PM: ❯ Version 5:13:26 PM: @netlify/build 6.0.0 5:13:26 PM: ​ 5:13:26 PM: ❯ Flags 5:13:26 PM: deployId: 5fd23afa57ada62de03f5432 5:13:26 PM: mode: buildbot 5:13:26 PM: ​ 5:13:26 PM: ❯ Current directory 5:13:26 PM: /opt/build/repo 5:13:26 PM: ​ 5:13:26 PM: ❯ Config file 5:13:26 PM: /opt/build/repo/netlify.toml 5:13:26 PM: ​ 5:13:26 PM: ❯ Context 5:13:26 PM: production 5:13:26 PM: ​ 5:13:26 PM: ──────────────────────────────────────────────────────────────── 5:13:26 PM: 1. build.command from netlify.toml 5:13:26 PM: ──────────────────────────────────────────────────────────────── 5:13:26 PM: ​ 5:13:26 PM: hugo --gc --minify
5:13:27 PM: go: bitbucket.org/olligranlund/hugo-theme@v0.0.0-20201210141922-d0aa2c04e524: reading https://api.bitbucket.org/2.0/repositories/olligranlund/hugo-theme?fields=scm: 403 Forbidden
5:13:27 PM: server response: Access denied. You must have write or admin access.
5:13:27 PM: hugo: collected modules in 829 ms
5:13:27 PM: Total in 830 ms
5:13:27 PM: Error: failed to download modules: go command failed: go: bitbucket.org/olligranlund/hugo-theme@v0.0.0-20201210141922-d0aa2c04e524: reading https://api.bitbucket.org/2.0/repositories/olligranlund/hugo-theme?fields=scm: 403 Forbidden
5:13:27 PM: server response: Access denied. You must have write or admin access.
5:13:27 PM: ​
5:13:27 PM: ────────────────────────────────────────────────────────────────
5:13:27 PM: “build.command” failed
5:13:27 PM: ────────────────────────────────────────────────────────────────
5:13:27 PM: ​
5:13:27 PM: Error message
5:13:27 PM: Command failed with exit code 255: hugo --gc --minify
5:13:27 PM: ​
5:13:27 PM: Error location
5:13:27 PM: In build.command from netlify.toml:
5:13:27 PM: hugo --gc --minify
5:13:27 PM: ​
5:13:27 PM: Resolved config
5:13:27 PM: build:
5:13:27 PM: command: hugo --gc --minify
5:13:27 PM: commandOrigin: config
5:13:27 PM: environment:
5:13:27 PM: - GOPRIVATE
5:13:27 PM: - NODE_VERSION
5:13:27 PM: - HUGO_VERSION
5:13:27 PM: - HUGO_ENV
5:13:27 PM: - HUGO_ENABLEGITINFO
5:13:27 PM: publish: /opt/build/repo/public
5:13:27 PM: Caching artifacts
5:13:27 PM: Started saving build plugins
5:13:27 PM: Finished saving build plugins
5:13:27 PM: Started saving pip cache
5:13:27 PM: Finished saving pip cache
5:13:27 PM: Started saving emacs cask dependencies
5:13:27 PM: Finished saving emacs cask dependencies
5:13:27 PM: Started saving maven dependencies
5:13:27 PM: Finished saving maven dependencies
5:13:27 PM: Started saving boot dependencies
5:13:27 PM: Finished saving boot dependencies
5:13:27 PM: Started saving rust rustup cache
5:13:27 PM: Finished saving rust rustup cache
5:13:27 PM: Started saving rust cargo bin cache
5:13:27 PM: Finished saving rust cargo bin cache
5:13:28 PM: Started saving go dependencies
5:13:29 PM: Finished saving go dependencies
5:13:33 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:13:33 PM: Failing build: Failed to build site
5:13:33 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
5:13:33 PM: Finished processing build request in 33.484213596s

Seems like moving away from Hugo Modules back to Git Submodules helped for this issue, but I got stuck on another issue instead. Making another thread for that since it’s not straight related to this.

HI, @olligranlund. Thanks for sharing the solution you discovered.