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: "no go-import meta tags" when fetching from a private GitLab repo #37504

Closed
2at2 opened this issue Feb 27, 2020 · 12 comments
Closed

cmd/go: "no go-import meta tags" when fetching from a private GitLab repo #37504

2at2 opened this issue Feb 27, 2020 · 12 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

@2at2
Copy link

2at2 commented Feb 27, 2020

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

$ go version
go version go1.13 darwin/amd64

Does this issue reproduce with the latest release?

Yeap

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

go env Output
$ go env

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/strebul/Library/Caches/go-build"
GOENV="/Users/strebul/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY="gitlab.com"
GONOSUMDB="gitlab.com"
GOOS="darwin"
GOPATH="/Users/strebul/dev/gospace"
GOPRIVATE="gitlab.com"
GOPROXY="direct"
GOROOT="/Users/strebul/.gvm/gos/go1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/strebul/.gvm/gos/go1.13/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/strebul/test/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kz/4rf1vvhj2kb910mwtq44qzvr0000gn/T/go-build698625701=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go mod init
go get gitlab.com/strebul/test_lib
go get gitlab.com/strebul/test_lib: unrecognized import path "gitlab.com/strebul/test_lib" (parse https://gitlab.com/strebul/test_lib?go-get=1: no go-import meta tags ())

CURL

curl https://gitlab.com/strebul/test_lib?go-get=1

<html><head><meta name="go-import" content="gitlab.com/strebul/test_lib git https://gitlab.com/strebul/test_lib.git" /><meta name="go-source" content="gitlab.com/strebul/test_lib https://gitlab.com/strebul/test_lib https://gitlab.com/strebul/test_lib/-/tree/master{/dir} https://gitlab.com/strebul/test_lib/-/blob/master{/dir}/{file}#L{line}" /></head><body>go get https://gitlab.com/strebul/test_lib</body></html>

What did you expect to see?

I want to obtain dependency.

With golang 1.14

go get gitlab.com/strebul/test_lib
go get gitlab.com/strebul/test_lib: unrecognized import path "gitlab.com/strebul/test_lib": reading https://gitlab.com/strebul/test_lib?go-get=1: 500 Internal Server Error
@bcmills
Copy link
Contributor

bcmills commented Feb 27, 2020

If the server is returning status 500, there isn't really anything the go command can do about that. (Open an issue with GitLab.)

FWIW, here's what I get:

example.com$ go version
go version devel +7bb33179 Thu Feb 27 05:56:21 2020 +0000 linux/amd64

example.com$ go mod init example.com
go: creating new go.mod: module example.com

example.com$ go get gitlab.com/strebul/test_lib
go get gitlab.com/strebul/test_lib: module gitlab.com/strebul/test_lib: git ls-remote -q origin in /tmp/tmp.GIerny0Ddu/_gopath/pkg/mod/cache/vcs/fe81d9efa2646d8017d2a3c892b3f5b0f3070c2aaf4304e69e8a35ab3e5b45e8: exit status 128:
        fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

Note that with Go 1.14, in order to access private GitLab repos you'll probably need to put some sort of credential in your .netrc file.

@bcmills bcmills changed the title no go-import meta tags cmd/go: "no go-import meta tags" when fetching from a private GitLab repo Feb 27, 2020
@bcmills
Copy link
Contributor

bcmills commented Feb 27, 2020

Also, go1.13 is missing quite a few critical patches. On the 1.13 line, you'll want to use go1.13.8 instead.

@bcmills
Copy link
Contributor

bcmills commented Feb 27, 2020

Please follow up with GitLab about the 500's and let us know if you're still having trouble.

@bcmills bcmills added 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. labels Feb 27, 2020
@bcmills bcmills added this to the Unplanned milestone Feb 27, 2020
@2at2
Copy link
Author

2at2 commented Feb 27, 2020

I did it before my test. I've putted my credentials to .netrc. For quick investigation I can add your email to repository gitlab.com/strebul/test_lib.

@2at2
Copy link
Author

2at2 commented Feb 27, 2020

I've installed go1.13.8 and there is the same error.

go version
go version go1.13.8 darwin/amd64

go get gitlab.com/strebul/test_lib
go get gitlab.com/strebul/test_lib: unrecognized import path "gitlab.com/strebul/test_lib" (parse https://gitlab.com/strebul/test_lib?go-get=1: no go-import meta tags ())

@bcmills
Copy link
Contributor

bcmills commented Mar 2, 2020

Yeah, I'm not sure why you'd be getting that error. If you can, add GitLab user bcmills to the test repo.

@2at2
Copy link
Author

2at2 commented Mar 2, 2020

@bcmills I've added you.

@bcmills
Copy link
Contributor

bcmills commented Mar 2, 2020

Thanks, I see it. I should have some time to look into this later this week.

@bcmills
Copy link
Contributor

bcmills commented Mar 4, 2020

Here's what I'm seeing with Go 1.14, with a GitLab access token in my .netrc file:

example.com$ go version
go version go1.14 linux/amd64

example.com$ go mod init example.com
go: creating new go.mod: module example.com

example.com$ GOPRIVATE=gitlab.com/strebul go get -d gitlab.com/strebul/test_lib
go: downloading gitlab.com/strebul/test_lib v0.0.0-20200227153846-ae6ce9befc25
go: gitlab.com/strebul/test_lib upgrade => v0.0.0-20200227153846-ae6ce9befc25
go get: gitlab.com/strebul/test_lib@v0.0.0-20200227153846-ae6ce9befc25: parsing go.mod:
        module declares its path as: test_lib
                but was required as: gitlab.com/strebul/test_lib

and basically the same with Go 1.13.8:

example.com$ go version
go version go1.13.8 linux/amd64

example.com$ go mod init example.com
go: creating new go.mod: module example.com

example.com$ GOPRIVATE=gitlab.com/strebul go get -d gitlab.com/strebul/test_lib
go: finding gitlab.com/strebul/test_lib latest
go: downloading gitlab.com/strebul/test_lib v0.0.0-20200227153846-ae6ce9befc25
go: extracting gitlab.com/strebul/test_lib v0.0.0-20200227153846-ae6ce9befc25
go get: gitlab.com/strebul/test_lib@v0.0.0-20200227153846-ae6ce9befc25: parsing go.mod:
        module declares its path as: test_lib
                but was required as: gitlab.com/strebul/test_lib

Both of those error messages seem to be accurate.

@bcmills
Copy link
Contributor

bcmills commented Mar 4, 2020

If I leave out GOPRIVATE, the error message is worse but still doesn't match the reported no go-import meta tags error:

example.com$ go version
go version go1.14 linux/amd64

example.com$ go mod init example.com
go: creating new go.mod: module example.com

example.com$ go get -d gitlab.com/strebul/test_lib
go: downloading gitlab.com/strebul/test_lib v0.0.0-20200227153846-ae6ce9befc25
go get gitlab.com/strebul/test_lib: gitlab.com/strebul/test_lib@v0.0.0-20200227153846-ae6ce9befc25: verifying module: gitlab.com/strebul/test_lib@v0.0.0-20200227153846-ae6ce9befc25: reading https://sum.golang.org/lookup/gitlab.com/strebul/test_lib@v0.0.0-20200227153846-ae6ce9befc25: 410 Gone
        server response:
        not found: gitlab.com/strebul/test_lib@v0.0.0-20200227153846-ae6ce9befc25: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/fe81d9efa2646d8017d2a3c892b3f5b0f3070c2aaf4304e69e8a35ab3e5b45e8: exit status 128:
                fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled

@bcmills
Copy link
Contributor

bcmills commented Mar 4, 2020

Is it possible that your machine is configured to use a proxy for HTTPS requests, and that proxy is somehow rewriting GitLab's response in a way that removes the go-import tags?

@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 Mar 4, 2020
@2at2
Copy link
Author

2at2 commented Mar 13, 2020

Hi,

I've compiled golang 1.14 with my fixes (file src/cmd/go/internal/web/http.go:96) and seen that gitlab responded with 500 status code on request with Authorization: Basic ***.
After some checks I've deleted auth data from my .netrc and got successful response with go-import meta. I don't know what updates gitlab made but I am going to report about that.

Finally to obtain private repository from gitlab:

  • Do not put credentials to .netrc
  • You need to add
    [url "git@gitlab.com:"] insteadOf = https://gitlab.com/
    to $HOME/.gitconfig

@2at2 2at2 closed this as completed Mar 13, 2020
@golang golang locked and limited conversation to collaborators Mar 13, 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

3 participants