Debian Bullseye building distrobuilder fails

I’ve just installed Incus on Bullseye, all up and running. I’ve then attempted to build from the Github 3.0 release code on Debian but it’s failing for me.

  nick@host:~/distrobuilder-distrobuilder-3.0$ make
  gofmt -s -w .
  go install -v ./...
  go: downloading github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3
  go: downloading gopkg.in/yaml.v2 v2.4.0
  go: downloading github.com/lxc/incus v0.0.0-20231030213510-385b6509cfce
  go: downloading github.com/spf13/cobra v1.7.0
  go: downloading github.com/sirupsen/logrus v1.9.3
  go: downloading github.com/mudler/docker-companion v0.4.6-0.20211015133729-bd4704fad372
  go: downloading github.com/google/go-github/v56 v56.0.0
  go: downloading gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4
  go: downloading github.com/spf13/pflag v1.0.5
  go: downloading github.com/spf13/jwalterweatherman v1.1.0
  go: downloading github.com/containerd/containerd v1.7.8
  go: downloading golang.org/x/sys v0.13.0
  go: downloading github.com/docker/docker v24.0.7+incompatible
  go: downloading github.com/opencontainers/umoci v0.4.8-0.20211009121349-9c76304c034d
  go: downloading github.com/opencontainers/runtime-spec v1.1.0
  go: downloading github.com/opencontainers/image-spec v1.1.0-rc5
  go: downloading github.com/apex/log v1.9.0
  go: downloading github.com/golang/protobuf v1.5.3
  go: downloading github.com/opencontainers/go-digest v1.0.0
  go: downloading github.com/klauspost/pgzip v1.2.6
  go: downloading github.com/vbatts/go-mtree v0.5.3
  go: downloading github.com/pkg/errors v0.9.1
  go: downloading github.com/heroku/docker-registry-client v0.0.0-20211012143308-9463674c8930
  go: downloading github.com/zitadel/oidc/v2 v2.11.0
  go: downloading github.com/pkg/sftp v1.13.6
  go: downloading github.com/gorilla/websocket v1.5.0
  go: downloading github.com/cyphar/filepath-securejoin v0.2.4
  go: downloading github.com/containerd/continuity v0.4.3
  go: downloading google.golang.org/protobuf v1.31.0
  go: downloading gopkg.in/antchfx/htmlquery.v1 v1.2.2
  go: downloading github.com/urfave/cli v1.22.14
  go: downloading golang.org/x/crypto v0.14.0
  go: downloading github.com/google/uuid v1.4.0
  go: downloading github.com/containerd/log v0.1.0
  go: downloading github.com/docker/distribution v2.8.3+incompatible
  go: downloading golang.org/x/net v0.17.0
  go: downloading github.com/fsouza/go-dockerclient v1.10.0
  go: downloading gopkg.in/square/go-jose.v2 v2.6.0
  go: downloading github.com/antchfx/xpath v1.2.5
  go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
  go: downloading github.com/klauspost/compress v1.17.2
  go: downloading golang.org/x/text v0.13.0
  go: downloading github.com/google/go-querystring v1.1.0
  go: downloading github.com/distribution/reference v0.5.0
  go: downloading github.com/gorilla/schema v1.2.0
  go: downloading github.com/moby/patternmatcher v0.6.0
  go: downloading github.com/cpuguy83/go-md2man v1.0.10
  go: downloading github.com/moby/sys/sequential v0.5.0
  go: downloading golang.org/x/sync v0.4.0
  go: downloading golang.org/x/term v0.13.0
  go: downloading github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
  go: downloading github.com/docker/go-units v0.5.0
  go: downloading github.com/kr/fs v0.1.0
  go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.3
  go: downloading golang.org/x/oauth2 v0.13.0
  go: downloading github.com/moby/term v0.5.0
  go: downloading github.com/rootless-containers/proto v0.1.1
  go: downloading github.com/opencontainers/runc v1.1.9
  go: downloading github.com/morikuni/aec v1.0.0
  go: downloading github.com/rootless-containers/proto/go-proto v0.0.0-20230421021042-4cd87ebadd67
  go: downloading google.golang.org/appengine v1.6.8
  go: downloading github.com/russross/blackfriday v1.6.0
  go: downloading github.com/docker/go-connections v0.4.0
  go: downloading github.com/russross/blackfriday/v2 v2.1.0
  go: downloading github.com/gorilla/securecookie v1.1.1
  go: downloading github.com/muhlemmer/gu v0.3.1
  go: downloading github.com/gogo/protobuf v1.3.2
  ../go/pkg/mod/golang.org/x/crypto@v0.14.0/curve25519/curve25519_go120.go:9:8: package crypto/ecdh is not in GOROOT (/usr/lib/go-1.15/src/crypto/ecdh)
  distrobuilder/main.go:59:2: package embed is not in GOROOT (/usr/lib/go-1.15/src/embed)
  make: *** [Makefile:9: default] Error 1

I got various issues as I compiled in Ubuntu. It went away by using latest go (not as apt or deb) and defined GOROOT manually, here the steps:

sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential debootstrap rsync gpg squashfs-tools git
wget  https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
tar -xvf go1.20.2.linux-amd64.tar.gz
sudo mv go /usr/local
export GOPATH=/usr/local/go/bin
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

check the version (1.20.2):
go version

git clone https://github.com/lxc/distrobuilder
cd distrobuilder
make
mv /usr/local/go/bin/bin/distrobuilder /usr/local/bin/

Thanks! It was the go version, mine was

go version go1.15.15 linux/amd64

I’ve found distrobuilder a necessity as I need to build the occasional i386 and armhf container now they’ve been removed from images: