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: The repository under multiple groups will not be available. #43142

Closed
divinerapier opened this issue Dec 11, 2020 · 3 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@divinerapier
Copy link

divinerapier commented Dec 11, 2020

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

$ go version
go version go1.15.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

GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/divinerapier/code/gopath/bin"
GOCACHE="/home/divinerapier/.cache/go-build"
GOENV="/home/divinerapier/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/divinerapier/code/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/divinerapier/code/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/divinerapier/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/divinerapier/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-build936972071=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I have a private repo: https://my.gitlab.com/group0/group1/group2/repo . And group0, group1 and group2 are all group names.

And then I want to use it as a dependency in another repo in go.mod file.

But go mod tidy -v thinks that the repo is my.gitlab.com/group0/group1

$ go mod tidy -v 
get "my.gitlab.com/group0/group1/group2/repo": found meta tag get.metaImport{Prefix:"my.gitlab.com/group0/group1", VCS:"git", RepoRoot:"https://my.gitlab.com/group0/group1.git"} at //my.gitlab.com/group0/group1/group2/repo?go-get=1

What did you expect to see?

I want the go mod works.

What did you see instead?

get "my.gitlab.com/group0/group1/group2/repo": found meta tag get.metaImport{Prefix:"my.gitlab.com/group0/group1", VCS:"git", RepoRoot:"https://my.gitlab.com/group0/group1.git"} at //my.gitlab.com/group0/group1/group2/repo?go-get=1
get "my.gitlab.com/group0/group1/group2/repo": verifying non-authoritative meta tag
go: my.gitlab.com/group0/group1/group2/repo@v0.0.3: reading my.gitlab.com/group0/group1/group2/repo/group2/repo/go.mod at revision group2/repo/v0.0.3: unknown revision group2/repo/v0.0.3

I add some logs in function repoRootForImportDynamic in file src/cmd/go/internal/get/vcs.go

func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) {
	url, err := urlForImportPath(importPath)
	if err != nil {
		return nil, err
	}
	fmt.Printf("importPath: %s, url: %v, err: %v\n", importPath, url, err)
	resp, err := web.Get(security, url)
	if err != nil {
		msg := "https fetch: %v"
		if security == web.Insecure {
			msg = "http/" + msg
		}
		return nil, fmt.Errorf(msg, err)
	}
	body := resp.Body
	defer body.Close()
	bodyData, err := ioutil.ReadAll(body)
	imports, err := parseMetaGoImports(bufio.NewReader(bytes.NewBuffer(bodyData)), mod)
	fmt.Printf("imports: %v, err: %v, \nbody: %s, \nmod: %v\n", imports, err, bodyData, mod)
...
	// Find the matched meta import.
	mmi, err := matchGoImport(imports, importPath)
	fmt.Printf("imports: %v, importPath: %v, mmi: %v, err: %v\n", imports, importPath, mmi, err)

...
}

logs are

importPath: my.gitlab.com/group0/group1/group2/repo, url: //my.gitlab.com/group0/group1/group2/repo?go-get=1, err: <nil>
imports: [{my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git}], err: <nil>, 
body: <html><head><meta name="go-import" content="my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git" /></head></html>, 
mod: 1
imports: [{my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git}], importPath: my.gitlab.com/group0/group1/group2/repo, mmi: {my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git}, err: <nil>

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 11, 2020
@toothrot toothrot added this to the Backlog milestone Dec 11, 2020
@toothrot toothrot changed the title The repository under multiple groups will not be available. cmd/go: The repository under multiple groups will not be available. Dec 11, 2020
@toothrot
Copy link
Contributor

/cc @bcmills @jayconrod @matloob

@bcmills
Copy link
Contributor

bcmills commented Dec 11, 2020

It looks like your server returned the wrong go-import meta tags for this path — this does not seem to be a bug in cmd/go. You'll need to open a ticket with whoever maintains your server (or perhaps with GitLab).

@bcmills bcmills closed this as completed Dec 11, 2020
@bcmills
Copy link
Contributor

bcmills commented Dec 11, 2020

See https://golang.org/ref/mod#vcs-find for documentation on the go-import protocol.

@golang golang locked and limited conversation to collaborators Dec 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants