Skip to content

cmd/go: 'go build' error from 'git ls-remote' when downloading from private repo #33836

@lihaic

Description

@lihaic

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

$ go version
go version go1.13rc1 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lhc/.cache/go-build"
GOENV="/home/lhc/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="*.bmi"
GONOSUMDB="*.bmi"
GOOS="linux"
GOPATH="/home/lhc/go"
GOPRIVATE="*.bmi"
GOPROXY="https://goproxy.io,direct"
GOROOT="/home/lhc/sdk/go1.13rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/lhc/sdk/go1.13rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/lhc/gitlab.bmi/tss/go.mod"
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=/tmp/go-build750408901=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I set two enviroment variable first.
$ go1.13rc1 env -w GOPROXY=https://goproxy.io,direct
$ go1.13rc1 env -w GOPRIVATE=*gitlab.bmi
Then i tried to build my project.
$ go1.13rc1 build -v
And then it failed, because some packages my project rely on is in a private repo.
The error message is:

# cd .; git ls-remote -- https://gitlab.bmi/aaa/logv
usage: git ls-remote [--heads] [--tags]  [--upload-pack=]
                     [-q | --quiet] [--exit-code] [--get-url] [ [...]]
# cd .; git ls-remote -- git+ssh://gitlab.bmi/aaa/logv
usage: git ls-remote [--heads] [--tags]  [--upload-pack=]
                     [-q | --quiet] [--exit-code] [--get-url] [ [...]]
# cd .; git ls-remote -- ssh://gitlab.bmi/aaa/logv
usage: git ls-remote [--heads] [--tags]  [--upload-pack=]
                     [-q | --quiet] [--exit-code] [--get-url] [ [...]]
go: gitlab.bmi/aaa/logv.git@v1.2.2: reading gitlab.bmi/aaa/logv.git/go.mod at revision v1.2.2: unknown revision v1.2.2

I thought this git ls-remote is trying to get tag info, is this supposed to be git ls-remote --tags or git ls remote

Then i modified the source code /home/lhc/sdk/go1.13rc1/src/cmd/go/internal/get/vcs.go line186
pingCmd: "ls-remote -- {scheme}://{repo}", ---> to pingCmd: "ls-remote {scheme}://{repo}",

And then i tried to run go1.13rc1 build -v, and it succeed.

What did you expect to see?

I hope after i set GOPROXY and GOPRIVATE, i could download package from both public repo and private repo.

What did you see instead?

But i can't run go build correctly.

Question is that is that line wrong?

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions