Skip to content
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: failed to fetch private repo with multiple error situations #38345

Closed
xrfang opened this issue Apr 10, 2020 · 8 comments
Closed

cmd/go: failed to fetch private repo with multiple error situations #38345

xrfang opened this issue Apr 10, 2020 · 8 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@xrfang
Copy link

xrfang commented Apr 10, 2020

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

$ go version
go version go1.14 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/xrfang/.cache/go-build"
GOENV="/home/xrfang/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE="git2.likeit.cn"
GONOPROXY="git2.likeit.cn"
GONOSUMDB="git2.likeit.cn"
GOOS="linux"
GOPATH="/home/xrfang/go"
GOPRIVATE="git2.likeit.cn"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/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=/tmp/go-build271669497=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I tried to migrate a project to use go modules: create empty go.mod file in the project source dir, then run go build ./....

What did you expect to see?

The project should be built successfully.

What did you see instead?

Got problem described here: https://stackoverflow.com/questions/60341591 I tried to ask new question on SO but get down voted. Then, I did the following test:

$ go get -v git2.likeit.cn/go/likesync
unrecognized import path "git2.likeit.cn/go/likesync": https fetch: Get "https://git2.likeit.cn/go/likesync?go-get=1": dial tcp 192.168.90.231:443: connect: connection refused

i.e. Go insist to get the repo via HTTPS but the private repo only provide HTTP. The problem was reported in #37943. However it re-appeared, despite the fact that all env was set according to that issue.

Then, I created an empty mod in that directory:

$ go mod init test
go: creating new go.mod: module test
$ go get -v git2.likeit.cn/go/likesync
get "git2.likeit.cn/go/likesync": found meta tag get.metaImport{Prefix:"git2.likeit.cn/go/likesync", VCS:"git", RepoRoot:"http://git2.likeit.cn/go/likesync.git"} at //git2.likeit.cn/go/likesync?go-get=1
get "git2.likeit.cn": found meta tag get.metaImport{Prefix:"git2.likeit.cn", VCS:"git", RepoRoot:"http://git2.likeit.cn//.git"} at //git2.likeit.cn/?go-get=1
get "git2.likeit.cn/go": found meta tag get.metaImport{Prefix:"git2.likeit.cn/go", VCS:"git", RepoRoot:"http://git2.likeit.cn/go/.git"} at //git2.likeit.cn/go?go-get=1
go: git2.likeit.cn/go/likesync upgrade => v1.5.3
go get: git2.likeit.cn/go/likesync@v1.5.3: parsing go.mod:
	module declares its path as: git.likeit.cn/go/likesync
	        but was required as: git2.likeit.cn/go/likesync

This time, it does not insist on HTTPS, but found an old location of the repo. There is a likesync package under git.likeit.cn/go/likesync, in that repo, there indeed has a go.mod file states: module git.likeit.cn/go/likesync. This repo was abandoned, albeit still accessible.

In the new repo git2.likeit.cn/go/likesync, their is no go.mod file. My problem is, WHY and HOW does the go build system find git.likeit.cn as the project ONLY refer to git2.likeit.cn??

@andybons andybons changed the title failed to fetch private repo with multiple error situations (was #37943) cmd/go: failed to fetch private repo with multiple error situations Apr 10, 2020
@andybons
Copy link
Member

@bcmills @matloob @jayconrod

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 10, 2020
@andybons andybons added this to the Unplanned milestone Apr 10, 2020
@bcmills
Copy link
Contributor

bcmills commented Apr 11, 2020

Are you sure that the repository at http://git2.likeit.cn/go/likesync.git at the commit tagged v1.5.3 does not have a go.mod file declaring module git.likeit.cn/go/likesync?

@bcmills bcmills added modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 11, 2020
@xrfang
Copy link
Author

xrfang commented Apr 13, 2020

@bcmills I will verify that tomorrow. However, the key problem is even if we have a go.mod file at git.likeit.cn/go/likesync@1.5.3, it does not explain why the go command try to find the module at git.likeit.cn?? in the entire project, there is only reference to git2.likeit.cn?

This is unbelivable... or, is it sooo intelligent to check git\d*.likeit.cn??

@bcmills
Copy link
Contributor

bcmills commented Apr 13, 2020

Nothing in that go command output indicates that it ever attempted to fetch anything from git.likeit.cn. The reported error is a path mismatch for the go.mod file found for git2.likeit.cn/go/likesync@v1.5.3.

@xrfang
Copy link
Author

xrfang commented Apr 14, 2020

yes, you are right, there is a module spec @v1.5.3. However, the master HEAD is newer than v1.5.3, and that go.mod file is deleted. Why it is still referenced?

@bcmills
Copy link
Contributor

bcmills commented Apr 14, 2020

Per go help get:

By default, get looks up the latest tagged release version, such as v0.4.5 or v1.2.3. If there are no tagged release versions, get looks up the latest tagged pre-release version, such as v0.0.1-pre1. If there are no tagged versions at all, get looks up the latest known commit.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 14, 2020
@xrfang
Copy link
Author

xrfang commented Apr 15, 2020

@bcmills OK. So the behavior is by design. Shall I close this ticket, or is there anything to investigate, given the different behavior of not having a go.mod, and having a go.mod?

@bcmills
Copy link
Contributor

bcmills commented Apr 15, 2020

I don't think there is anything more to do here, so closing. Please do let us know if you run into other issues, though. (We know that the documentation & test coverage for private repos still needs some polish.)

@bcmills bcmills closed this as completed Apr 15, 2020
@golang golang locked and limited conversation to collaborators Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants