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: can't work on project in $GOPATH/pkg/mod #35485

Open
jiacai2050 opened this issue Nov 10, 2019 · 6 comments

Comments

@jiacai2050
Copy link

@jiacai2050 jiacai2050 commented Nov 10, 2019

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?

Yes

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

go env Output
$ go env

GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/chenxiang/Library/Caches/go-build"
GOENV="/Users/chenxiang/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/chenxiang/code/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/Users/chenxiang/.goenv/versions/1.13.0"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/chenxiang/.goenv/versions/1.13.0/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fq/zphbvlvx6bxbq03lts1v2dnr0000gp/T/go-build949244485=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Use emacs + gopls to navigate project in $GOPATH/pkg/mod

What did you expect to see?

No error

What did you see instead?

LSP :: Connected to [gopls:94397 status:starting].
LSP :: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: error writing go.mod: open $GOPATH/pkg/mod/github.com/cep21/circuit/v3@v3.1.0/go.mod298498081.tmp: permission denied
@gopherbot gopherbot added this to the Unreleased milestone Nov 10, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 10, 2019

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@ianthehat

This comment has been minimized.

Copy link

@ianthehat ianthehat commented Nov 10, 2019

If you tried to directly open that folder, I would expect it to fail. gopls is designed to start from a valid project root (a writable source folder either in your GOPATH or with a go.mod and go.sum).

Nothing in $GOPATH/pkg/mod is a valid project, or should be opened directly as one, it is just a download cache for modules. The folders may not have correct go.mod files, and even if they do they are not writeable ones.

If you just want to explore the code, create a trivial project that depends on that module and open that instead.

@jiacai2050

This comment has been minimized.

Copy link
Author

@jiacai2050 jiacai2050 commented Nov 10, 2019

No, I don't use gopls in $GOPATH/pkg/mod directly, but rather jump there by lsp-find-definition from my own app.

@muirdm

This comment has been minimized.

Copy link

@muirdm muirdm commented Nov 11, 2019

I don't have any issues poking around in the mod cache in Emacs. Are you using a using a current version of lsp-mode? Can you provide steps to reproduce the issue?

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Nov 11, 2019

Note that the combination of CL 204521 and CL 204878 (both upcoming in Go 1.14) will make go list, go test, etc. within the module cache much more likely to succeed.

That may also make the behavior of gopls more sensible for (read-only) workspaces within the module cache.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Nov 11, 2019

(And #34506 makes it so that gopls could potentially even resolve missing dependencies.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.