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: "failed to cache compiled Go files" error when calling Formatting #36511

Closed
myitcv opened this issue Jan 11, 2020 · 4 comments
Closed

Comments

@myitcv
Copy link
Member

@myitcv myitcv commented Jan 11, 2020

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

$ go version
go version devel +693748e9fa Mon Jan 6 11:46:56 2020 +0000 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20200107184032-11e9d9cc0042 => github.com/myitcvforks/tools v0.0.0-20200108093634-093e5cb57410
$ go list -m golang.org/x/tools/gopls
golang.org/x/tools/gopls v0.1.8-0.20200107184032-11e9d9cc0042 => github.com/myitcvforks/tools/gopls v0.0.0-20200108093634-093e5cb57410

The replace directive versions are described here:

govim/govim@afa4918

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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build460580672=/tmp/go-build -gno-record-gcc-switches"

What did you do?

govim has a test that verifies the behaviour of calling goimports (via CodeAction) and then Formatting.

The sequence is:

  • open file
  • run CodeAction and then Formatting
  • compare the result vs a known golden file

We have just seen the Formatting call fail in one of our CI builds with the following error:

getting file for Format: go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- os]: exit status 1: go build os/signal: failed to cache compiled Go files

What did you expect to see?

No error

What did you see instead?

As above. The gopls log is as follows: gopls.log


cc @stamblerre

FYI @leitzler

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jan 12, 2020

Change https://golang.org/cl/214421 mentions this issue: internal/lsp: don't require type-checking for formatting

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Jan 12, 2020

This looks like a go list error message, so my guess is that the go/packages.Load must have failed for some reason, which caused this response. I mailed the above CL to remove the need for go list to run on a formatting request, but fundamentally we can't really do anything else about a go list error. In the typical case, we would try to run go/packages.Load again if we failed on a prior request.

@stamblerre stamblerre modified the milestones: Unreleased, gopls v1.0 Jan 13, 2020
@myitcv

This comment has been minimized.

Copy link
Member Author

@myitcv myitcv commented Jan 13, 2020

but fundamentally we can't really do anything else about a go list error

I agree if the error from go list is a known "good" error. But in this case I'm not clear that it's an expected potential outcome from what we were trying to do at the time.

gopherbot pushed a commit to golang/tools that referenced this issue Jan 13, 2020
We had previously required a type-checked package for formatting
requests, in order to determine if the package contained any parse
errors. We can get this information directly from the ParseGoHandle, so
there is no need to check the package. This will prevent `go list`
errors from making their way into formatting requests, for which a `go
list` really is not needed.

Updates golang/go#36511

Change-Id: I297f8880367e800d2343f468535efa80d2937071
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214421
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Jan 14, 2020

Not sure if the go list error was "known", but it doesn't seem like something we can necessarily avoid. Please open a new issue if you see this again. The above CL has been merged, so now go list errors won't affect formatting results.

@stamblerre stamblerre closed this Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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