Go: cmd/go: "fatal: git fetch-pack: expected shallow list" when retrieving earlier version of already installed package on CentOS 7.

Created on 11 Apr 2020  路  11Comments  路  Source: golang/go

What version of Go are you using (go version)?

$ go version
go version go1.13.6 linux/amd64

Does this issue reproduce with the latest release?

Not sure, but this is the latest supported version for CentOS 7.

What operating system and processor architecture are you using (go env)?

CentOS 7.

go env Output

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/users/d00u3151/.cache/go-build"
GOENV="/users/d00u3151/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/users/d00u3151/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/users/d00u3151/tmp/go-build945266341=/tmp/go-build -gno-record-gcc-switches"
[d00u3151@pde-bsp3hq2 dan]$

What did you do?

Tried to build the latest unreleased version of reposurgeon (problem does not occur with reposurgeon release 4.5).

$ git clone https://gitlab.com/esr/reposurgeon.git
Cloning into 'reposurgeon'...
remote: Enumerating objects: 1203, done.
remote: Counting objects: 100% (1203/1203), done.
remote: Compressing objects: 100% (456/456), done.
remote: Total 33416 (delta 890), reused 1009 (delta 739), pack-reused 32213
Receiving objects: 100% (33416/33416), 550.06 MiB | 11.28 MiB/s, done.
Resolving deltas: 100% (22980/22980), done.
$ cd reposurgeon
$ git checkout -q b392d176f30825d150b828c4df3d2d8e2b3166f7 # version as of April 10, 2020
$ make
asciidoctor -a nofooter -b manpage reposurgeon.adoc
asciidoctor -a nofooter -b manpage repocutter.adoc
asciidoctor -a nofooter -b manpage repomapper.adoc
asciidoctor -a nofooter -b manpage repotool.adoc
asciidoctor -a nofooter -b manpage repobench.adoc
asciidoctor -a webfonts! reposurgeon.adoc
asciidoctor -a webfonts! repocutter.adoc
asciidoctor -a webfonts! repomapper.adoc
asciidoctor -a webfonts! repotool.adoc
asciidoctor -a webfonts! repobench.adoc
asciidoctor -a webfonts! repository-editing.adoc
go build -gcflags '-N -l' -o repocutter ./cutter
go: github.com/go-delve/[email protected] requires
        github.com/sirupsen/[email protected]: invalid version: git fetch --unshallow -f origin in /users/d00u3151/go/pkg/mod/cache/vcs/020616345f7c7f88438c217f9d0e26744bce721c80e4a28f93399a8a4cd2acf1: exit status 128:
        fatal: git fetch-pack: expected shallow list
make: *** [build] Error 1
$ make
go build -gcflags '-N -l' -o repocutter ./cutter
go: github.com/go-delve/[email protected] requires
        golang.org/x/[email protected]: invalid version: git fetch --unshallow -f https://go.googlesource.com/arch in /users/d00u3151/go/pkg/mod/cache/vcs/a260a67b53c91dca287c34ff2bdee130be447c2ea411a64bf4489a69e886411b: exit status 128:
        fatal: git fetch-pack: expected shallow list
make: *** [build] Error 1

What did you expect to see?

A successful build.

What did you see instead?

A cryptic error message.

This seems to occur when multiple versions of the same package are required. In this case, the go.mod contains golang.org/x/arch v0.0.0-20200312215426-ff8b605520f4 and github.com/go-delve/delve v1.4.0, but delve v1.4.0 has a dependency on: golang.org/x/[email protected]. It seems that trying to get the earlier version of arch when the later version has already been retrieved causes this error message.

In this case I was able to work around and successfully build by removing the reference to the later version of arch from go.mod.

NeedsInvestigation modules

Most helpful comment

I just ran into this issue on CentOS 7.8 (released September 24, 2019), with golang and git both installed via yum (from CentOS repos).

go version go1.13.6 linux/ppc64le
git version 1.8.3.1

I resolved this by uninstalling go 1.13.6 via yum and installing go 1.14.2 from https://golang.org/dl/

All 11 comments

this looks like the git command being too old to support shallow, solutions would be to upgrade git and/or enable the module proxy so git is no longer necessary

Also, see reposurgeon bug #272: https://gitlab.com/esr/reposurgeon/-/issues/272

Strange thing is if I manually create a shallow clone, git fetch --unshallow works fine. I'm not sure what is different about the shallow clones that go retrieves vs. the following:

$ git version
git version 1.8.3.1
$ git clone --depth 1 --bare https://go.googlesource.com/arch
Cloning into bare repository 'arch.git'...
remote: Counting objects: 144, done
remote: Finding sources: 100% (144/144)
remote: Total 144 (delta 11), reused 129 (delta 11)
Receiving objects: 100% (144/144), 768.76 KiB | 0 bytes/s, done.
Resolving deltas: 100% (11/11), done.
$ cd arch.git
$ git log --all --oneline
ff8b605 vendor: delete
$ git fetch --unshallow -f https://go.googlesource.com/arch
remote: Total 614 (delta 228), reused 614 (delta 228)
Receiving objects: 100% (614/614), 1.47 MiB | 0 bytes/s, done.
Resolving deltas: 100% (228/228), done.
From https://go.googlesource.com/arch
 * branch            HEAD       -> FETCH_HEAD
$ git log --all --oneline
ff8b605 vendor: delete
69f17b2 vendor: migrate from govendor to go mod vendor
368ea8f x86asm: add support for FLDZ and FLDLN2
a0d8588 arm64/arm64asm: rename NOP instruction as NOOP in go syntax
4e8777c arm64/arm64gen: get system register readable and writeable attribute
1137aed arm64/arm64gen: adds a generator sysreggen.go
[...snip...]

See also #26746 and #29114.

Also, old git clients have a bug for which the cmd/go workaround (#34092) has probably not been backported. You may need to upgrade to Go 1.14.1 if you are affected.

FYI, previous issues mentioned problems on CentOS 5 & CentOS 6. CentOS 5 is no longer supported, and CentOS 6 is reaching end-of-life later this year, but CentOS 7 is being supported until 2024.

I just ran into this issue on CentOS 7.8 (released September 24, 2019), with golang and git both installed via yum (from CentOS repos).

go version go1.13.6 linux/ppc64le
git version 1.8.3.1

I resolved this by uninstalling go 1.13.6 via yum and installing go 1.14.2 from https://golang.org/dl/

Faced with the same issues go version and git version are the same,
after second run error is the next

env GO111MODULE=on go run build/ci.go install ./cmd/geth
build command-line-arguments: cannot load golang_org/x/crypto/chacha20poly1305: cannot find module providing package golang_org/x/crypto/chacha20poly1305
make: * [geth] Error 1

Same issue here, same solution: remove EPEL's go 1.13 and install 1.14 directly from the vendor:

yum remove golang-bin
wget https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz
etc.

Same issue!

Unfortunately old platforms (and BTW Centos7 is not THAT old) are still vital in enterprise environment where stability is required, the suggestion to update git is a valid one but it really hamper down the velocity and ergonomics of go.

We have had similar issues running Bitbucket on RHEL7 in production needing a later version of the Git client. We have always found the IUS version to be very stable for production. Go to https://repo.ius.io/ to learn more.

Here are the basic steps to get the newer version of Git on Centos7/RHEL7:

yum -y erase git
yum -y install https://repo.ius.io/ius-release-el7.rpm
yum -y install git222

After updating to Git 2.2.2 the go get commands were successful.

Was this page helpful?
0 / 5 - 0 ratings