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/cmd/gopls: "build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined" #32238

Closed
23doors opened this issue May 24, 2019 · 8 comments

Comments

@23doors
Copy link

@23doors 23doors commented May 24, 2019

What did you do?

Open go file in VSCode configured for using gopls language server.

What did you expect to see?

No errors and working gopls.

What did you see instead?

Error on my package statement:

[Error - 11:39:40 PM] unable to check package for file:///<removed>.go: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined

Build info

Installed gopls through:

go get -u golang.org/x/tools/cmd/gopls

This used to work a few days ago so I tested different commits and it seems that:
2c78df6 is the most recent one that works (no errors). And next one: golang/tools@7927dba causes it to break.

Go info

go version go1.12.5 darwin/amd64
@gopherbot gopherbot added this to the Unreleased milestone May 24, 2019
@gopherbot gopherbot added the gopls label May 24, 2019
@zchee
Copy link
Contributor

@zchee zchee commented May 27, 2019

@23doors
Maybe it's workaround, but just set "gopls.env": {"GOPATH": "your gopath", "GOCACHE": "your gocache"} to your settings.json (settings.json is correct name? I forgot. I don't usually use vscode, I'm Neovim user)

Also, Now typing iPhone. might be invalid json syntax, sorry.

@23doors
Copy link
Author

@23doors 23doors commented May 27, 2019

@zchee this fixed it, thank you! But on 2c78df6 I wasn't required to set it, so this seems like a regression or a vscode-go issue. Also, I used same GOPATH and GOCACHE as from go env output.

@zchee
Copy link
Contributor

@zchee zchee commented May 27, 2019

@23doors
yes, maybe caused by any regression or vscode-go issue.

Also, I used same GOPATH and GOCACHE as from go env output.

It means set settings.json to same values from go env, right?
If so, your seeting is correct. seems to now didn't parses GOPATH and GOCACHE or some values caused by any bugs.

Unfortunately, I don't know which is buggy, because I first read gopls source code and first lauch vscode yesterday lol
I found this workaround when debugging this issue:
#29202 (comment)

@bcmills
Copy link
Member

@bcmills bcmills commented May 28, 2019

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented May 28, 2019

Can you provide a gopls log with redacted filenames? It can be found by going to "View: Debug Console" -> "Output" -> "Tasks" -> "gopls". At the very least, the top of your log would be helpful because it prints out your environment information. The error message you provided is surprising because we never run any go list command that looks like that.

@23doors
Copy link
Author

@23doors 23doors commented May 28, 2019

@stamblerre here it is, redacted file names and removed duplicate messages:

[Info  - 10:03:05 PM] #### Build info

no module information, gopls not built in module mode


#### Go info

go version go1.12.5 darwin/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/V/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/V/Go"
GOPROXY="https://proxy.golang.org"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
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 -w"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pd/hq5jjzqd6wq07z6xcrc1875m0000gr/T/go-build712859041=/tmp/go-build -gno-record-gcc-switches -fno-common"

[Error - 10:03:05 PM] unable to check package for file:///Users/V/Projects/redacted.go: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined

[Error - 10:03:06 PM] failed to deliver diagnostic for file:///Users/V/Projects/redacted/go%20%5Blist%20-f%20%7B%7Bcontext.GOARCH%7D%7D%20%7B%7Bcontext.Compiler%7D%7D%20--%20unsafe%5D: unsupported file extension: .Compiler}} -- unsafe]
[Error - 10:03:06 PM] unable to check package for file:///Users/V/Projects/redacted.go: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined

[Error - 10:03:06 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/V/Projects/redacted.go
  Code: 0 
[Error - 10:03:06 PM] unable to check package for file:///Users/V/Projects/redacted.go: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined

[Error - 10:03:06 PM] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/V/Projects/redacted.go
  Code: 0 
[Error - 10:03:06 PM] unable to check package for file:///Users/V/Projects/redacted.go: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined

[Error - 10:03:06 PM] Request textDocument/hover failed.
  Message: no AST for file:///Users/V/Projects/redacted.go
  Code: 0 
@bcmills bcmills removed the WaitingForInfo label May 28, 2019
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented May 28, 2019

Thank you for sharing! I was actually just able to reproduce this error, so I will be investigating it ASAP.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented May 29, 2019

This should be fixed with https://golang.org/cl/179221.

@stamblerre stamblerre closed this May 29, 2019
@golang golang locked and limited conversation to collaborators May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.