Skip to content

cmd/go: The repository under multiple groups will not be available. #43142

Closed
@divinerapier

Description

@divinerapier

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>

Activity

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Dec 11, 2020
added this to the Backlog milestone on Dec 11, 2020
changed the title [-]The repository under multiple groups will not be available.[/-] [+]cmd/go: The repository under multiple groups will not be available.[/+] on Dec 11, 2020
toothrot

toothrot commented on Dec 11, 2020

@toothrot
Contributor
bcmills

bcmills commented on Dec 11, 2020

@bcmills
Contributor

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 commented on Dec 11, 2020

@bcmills
Contributor

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

locked and limited conversation to collaborators on Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @toothrot@bcmills@gopherbot@divinerapier

        Issue actions

          cmd/go: The repository under multiple groups will not be available. · Issue #43142 · golang/go