profile
viewpoint

Ask questionsx/tools/cmd/gopls: "build cache is required, but could not be located: GOCACHE is not defined and $HOME is not defined"

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: 2c78df6d2ceec2cde4b7bff46c9b42cd05742fe1 is the most recent one that works (no errors). And next one: https://github.com/golang/tools/commit/7927dbab1be7d178ed14189b31e26c604b8baba8 causes it to break.

Go info

go version go1.12.5 darwin/amd64
golang/go

Answer questions 23doors

@zchee this fixed it, thank you! But on 2c78df6d2ceec2cde4b7bff46c9b42cd05742fe1 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.

useful!
source:https://uonfu.com/
answerer
Robert Kopaczewski 23doors 23doors Warsaw, Poland http://23doors.com Experienced Platform Architect skilled in Python, Golang, NodeJS and PostgreSQL. Focused on scalable and large scale architectures.
Github User Rank List