New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: improved failing messages needed for git version 1.7.1 on CentOS6 #28825

Open
RocFang opened this Issue Nov 16, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@RocFang

RocFang commented Nov 16, 2018

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

$ go version
go version go1.11.2 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/project/amigo/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-build784959064=/tmp/go-build"

What did you do?

reproducing is quite easy:

package main
import("bazil.org/fuse")
import("fmt")

func main(){
    var a fuse.DirentType
    a = 3

    fmt.Printf("%s,a=%d\n" ,"Hello", a)

}
  1. go mod init github.com/RocFang/test
  2. go get ./...

What did you expect to see?

go module works fine.
Even if git version not supported, we need a message to tell us what's the problem.

What did you see instead?

some strange failing messages comes out, like below:

build github.com/RocFang/test: cannot find module for path bazil.org/fuse

But when i check the details of the go cmd, i fount message has nothing to do with the true reason.
The true reasons are:

  1. When git version is too old, some git command fails, but the error checking does not deal with it well enough.
  2. The code fragments where "cannot find module for path" comes out is the calling of mdeps[findModule(path, dep)] = true in function PackageBuildInfo() resides in cmd/go/internal/modload/build.go.
  3. The buildList has only one item, and the only one itme is the main module in this situation.That is github.com/RocFang/test in this example.

related issues

  1. #28550
  2. #28064

@ianlancetaylor ianlancetaylor changed the title from improved failing messages needed for git version 1.7.1 on CentOS6 to cmd/go: improved failing messages needed for git version 1.7.1 on CentOS6 Nov 16, 2018

@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Nov 16, 2018

@bcmills

This comment has been minimized.

Member

bcmills commented Nov 16, 2018

But when i check the details of the go cmd, i fount message has nothing to do with the true reason.

Please post the complete output that you saw. (If we don't know what's broken, we can't fix it, and “cannot find module” is a perfectly reasonable failure message if we already gave more detail on a previous line.)

When git version is too old, some git command fails, but the error checking does not deal with it well enough.

See previously #26594.

@gopherbot gopherbot removed the NeedsFix label Nov 16, 2018

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 16, 2018

@RocFang

This comment has been minimized.

RocFang commented Nov 17, 2018

@bcmills Thanks for you reply.

Let me put all information below.

env

$cat /etc/redhat-release
CentOS release 6.9 (Final)
$git version
git version 1.7.1

build

$mkdir test
$cd test

$echo  'package main
import("bazil.org/fuse")
import("fmt")

func main(){
    var a fuse.DirentType
    a = 3

    fmt.Printf("%s,a=%d\n" ,"Hello", a)

}' >test.go
$go mod init github.com/RocFang/test
go: creating new go.mod: module github.com/RocFang/test

$go build
build github.com/RocFang/test: cannot find module for path bazil.org/fuse

$go build -x
# /root/go/pkg/mod/cache/vcs/f054a06a6621ae5a0d35bd57c2aabc6859f120ea524cc972ce3045b827e254ac for git2 https://github.com/bazil/fuse
cd /root/go/pkg/mod/cache/vcs/f054a06a6621ae5a0d35bd57c2aabc6859f120ea524cc972ce3045b827e254ac; git ls-remote -q https://github.com/bazil/fuse
0.003s # cd /root/go/pkg/mod/cache/vcs/f054a06a6621ae5a0d35bd57c2aabc6859f120ea524cc972ce3045b827e254ac; git ls-remote -q https://github.com/bazil/fuse
build github.com/RocFang/test: cannot find module for path bazil.org/fuse

This is a example small enough.
As we see, enven when we do go build -x, the git commands have no warnning/error message. It actually fails. When I exec git command manuay, the info is below:

$cd /root/go/pkg/mod/cache/vcs/f054a06a6621ae5a0d35bd57c2aabc6859f120ea524cc972ce3045b827e254ac
$git ls-remote -q https://github.com/bazil/fuse
usage: git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>] <repository> <refs>...

But these info not appear in the output of go build -x,so the last message cannot find module for path bazil.org/fuse is quite confusing.

@bcmills bcmills removed the WaitingForInfo label Nov 17, 2018

@bcmills

This comment has been minimized.

Member

bcmills commented Nov 17, 2018

Thanks for the detail!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment