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

x/tools/gopls: gopls errors out without access to a repo, even if repo is vendored #41301

Closed
evanmoses-okta opened this issue Sep 9, 2020 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@evanmoses-okta
Copy link

evanmoses-okta commented Sep 9, 2020

What did you do?

We have a private repo that contains a dep, and not everyone (including me) has read access to the repo. However, the repo is vendored and the source is available in the vendor directory.

For example

module myproduct

go 1.13

require (
        github.com/apublic/repo v0.0.0-date-sha
)

replace (
 	// security hotfix
	github.com/apublic/repo => github.com/private/repo v0.0.0-date-sha
)

Note that the vendored source is available at myproduct/vendor/github.com/apublic/repo

What did you expect to see?

All tooling should work normally. I don't understand why gopls is attempting to fetch source from the repo instead of using the vendored source.

What did you see instead?

"Repository not found" errors (with user and repo information redacted):

MYLAPTOP:myproduct me$ gopls -rpc.trace -v check backend/config/config.go
2020/09/09 12:18:08 Info:2020/09/09 12:18:08 Build info
----------
golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.4.4 h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20200731060945-b5fad4ed8dd6 h1:qKpj8TpV+LEhel7H/fR788J+KvhWZ3o3V6N2fU/iuLU=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
    mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info
-------
go version go1.14.5 darwin/amd64


2020/09/09 12:18:08 Info:2020/09/09 12:18:08 go env for /Users/me/dev/go/src/myproduct
(root /Users/me/dev/go/src/myproduct)
(valid build configuration = true)
(build flags: [])
GOCACHE=/Users/me/Library/Caches/go-build
GOFLAGS=
GOINSECURE=
GONOPROXY=
GOROOT=/usr/local/Cellar/go/1.14.5/libexec
GOMOD=/Users/me/dev/go/src/myproduct/go.mod
GOPATH=/Users/me/dev/go
GOPROXY=https://proxy.golang.org,direct
GOSUMDB=sum.golang.org
GO111MODULE=on
GONOSUMDB=
GOPRIVATE=
GOMODCACHE=

2020/09/09 12:18:10 Error:2020/09/09 12:18:10 go/packages.Load: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -modfile=/var/folders/_m/8vc05c994b35bl9vgctvkykc0000gn/T/go.6e9640b973d1c730975d6fe1fc1140ced342889bd3a9482827ed0710a989b231.349633255.mod -- ./... builtin]: exit status 1: go: github.com/aprivate/repo@v0.0.0-date-sha: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /Users/me/dev/go/pkg/mod/cache/vcs/962ed435a41c24ecbbc673554a66308c444dfa2f311556bba257cf2483e61f47: exit status 128:
	remote: Repository not found.
	fatal: repository 'https://github.com/private/repo/' not found

	snapshot=0
	directory=/Users/me/dev/go/src/myprodcut
	query=[./... builtin]
	packages=0
2020/09/09 12:18:10 Error:2020/09/09 12:18:10 initial workspace load failed: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -modfile=/var/folders/_m/8vc05c994b35bl9vgctvkykc0000gn/T/go.6e9640b973d1c730975d6fe1fc1140ced342889bd3a9482827ed0710a989b231.349633255.mod -- ./... builtin]: exit status 1: go: github.com/private/repo@v0.0.0-date-sha: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /Users/me/dev/go/pkg/mod/cache/vcs/962ed435a41c24ecbbc673554a66308c444dfa2f311556bba257cf2483e61f47: exit status 128:
	remote: Repository not found.
	fatal: repository 'https://github.com/private/repo/' not found
: packages.Load error
2020/09/09 12:18:10 Error:2020/09/09 12:18:10 warning: diagnose go.mod: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -modfile=/var/folders/_m/8vc05c994b35bl9vgctvkykc0000gn/T/go.6e9640b973d1c730975d6fe1fc1140ced342889bd3a9482827ed0710a989b231.349633255.mod -- ./... builtin]: exit status 1: go: github.com/private/repo@v0.0.0-date-sha: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /Users/me/dev/go/pkg/mod/cache/vcs/962ed435a41c24ecbbc673554a66308c444dfa2f311556bba257cf2483e61f47: exit status 128:
	remote: Repository not found.
	fatal: repository 'https://github.com/private/repo/' not found
: packages.Load error
	directory=/Users/me/dev/go/src/myproduct

Build info

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.4.4 h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20200731060945-b5fad4ed8dd6 h1:qKpj8TpV+LEhel7H/fR788J+KvhWZ3o3V6N2fU/iuLU=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
    mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info

go version go1.14.5 darwin/amd64

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 9, 2020
@gopherbot gopherbot added this to the Unreleased milestone Sep 9, 2020
@heschi
Copy link
Contributor

heschi commented Sep 9, 2020

Please try adding -mod=vendor to your configuration, or changing the go 1.13 in the go.mod to go 1.14 so that automatic vendoring mode kicks in.

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 9, 2020
@stamblerre stamblerre removed this from the Unreleased milestone Sep 9, 2020
@evanmoses-okta
Copy link
Author

OK, setting GOFLAGS=-mod=vendor seems to solve this problem for me...I'll see if there's anything stopping us from bumping the go version in go.mod. There's no way to set mod=vendor per-project without bumping the version, is there? I searched docs and couldn't find anything.

@heschi
Copy link
Contributor

heschi commented Sep 10, 2020

Correct. Automatic vendoring mode is the intended solution to that; there should be no significant problems increasing the version declared in the go.mod AFAIK.

@heschi heschi closed this as completed Sep 10, 2020
@golang golang locked and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. 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