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: 'no file information for file' problem #32142

Closed
bitfield opened this issue May 19, 2019 · 11 comments
Closed

x/tools/cmd/gopls: 'no file information for file' problem #32142

bitfield opened this issue May 19, 2019 · 11 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bitfield
Copy link

The attached source code causes gopls to fail:

[Info  - 12:55:14 PM] add view paasio as file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio
[Info  - 12:55:15 PM] #### Build info

golang.org/x/tools/cmd/gopls
    golang.org/x/tools@v0.0.0-20190511041617-99f201b6807e h1:wTxRxdzKt8fn3IQa3+kVlPJMxK2hJj2Orm+M2Mzw9eg=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=


#### Go info

go version go1.12.5 darwin/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/john/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/john/go"
GOPROXY=""
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="/dev/null"
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/q3/ybqqxyh92yd0yc865zqk0vpm0000gn/T/go-build251987466=/tmp/go-build -gno-record-gcc-switches -fno-common"

[Error - 12:55:15 PM] Request textDocument/documentLink failed.
  Message: no file information for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 

Hover doc does not work, and nor does auto-imports:

[Error - 12:56:26 PM] Request textDocument/hover failed.
  Message: no file information for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 12:56:27 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 12:56:27 PM] Request textDocument/formatting failed.
  Message: no file information for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 

Here is the code:

paasio.tar.gz

It builds correctly and passes tests on go1.12.5 darwin/amd64.

@gopherbot gopherbot added this to the Unreleased milestone May 19, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label May 19, 2019
@ianthehat
Copy link

I notice your GOPATH is set to /Users/john/go but the code is checked out below /Users/john/git/bitfield/exercism/users/bcc32/go/paasio and you have no go.mod file, which implies you are using neither GOPATH or modules.
Although GOMOD is set to /dev/null, which you only normally see when running in forced module mode without a module, which does not work well.

Checked out into my GOPATH, or after running go mod init it works fine for me.

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 20, 2019
@bcmills
Copy link
Contributor

bcmills commented May 20, 2019

@bitfield, can you confirm your GO111MODULE setting?

When you say “It builds correctly and passes tests on go1.12.5 darwin/amd64”, what is the exact command line and working directory with which you observed it to pass?

@bcmills
Copy link
Contributor

bcmills commented May 20, 2019

The attached source code

Please provide Playground links and/or a go get-able path rather than a tarball.

@evandigby
Copy link

The build info for x/tools in your description shows a commit prior to the fix for a similar issue you opened previously (#31712 (comment)). You may want to try updating gopls and see if it persists!

There’s a good chance it’s an entirely different issue since that “no information” error seems to be a bit if a catch-all. It probably would be good to add more logging around that area.

@bitfield
Copy link
Author

I notice your GOPATH is set to /Users/john/go but the code is checked out below /Users/john/git/bitfield/exercism/users/bcc32/go/paasio and you have no go.mod file, which implies you are using neither GOPATH or modules.

Correct. This is an Exercism solution.

Checked out into my GOPATH, or after running go mod init it works fine for me.

I don't dispute that.

@bitfield, can you confirm your GO111MODULE setting?

GO111MODULE is not set.

When you say “It builds correctly and passes tests on go1.12.5 darwin/amd64”, what is the exact command line and working directory with which you observed it to pass?

go test
PASS
ok      _/Users/john/git/bitfield/exercism/users/bcc32/go/paasio        2.116s

pwd
/Users/john/git/bitfield/exercism/users/bcc32/go/paasio

Please provide Playground links and/or a go get-able path rather than a tarball.

https://play.golang.org/p/_p1Czb1q5ky

The build info for x/tools in your description shows a commit prior to the fix for a similar issue you opened previously (#31712 (comment)). You may want to try updating gopls and see if it persists!

Yes, it persists. The output is now:

[Info  - 10:13:05] #### 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/john/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/john/go"
GOPROXY=""
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="/dev/null"
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/q3/ybqqxyh92yd0yc865zqk0vpm0000gn/T/go-build687648160=/tmp/go-build -gno-record-gcc-switches -fno-common"

[Error - 10:13:06] unable to read file /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: open /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: no such file or directory
[Error - 10:13:06] unable to read file /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: open /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: no such file or directory
[Error - 10:13:06] failed to deliver diagnostic for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go%20%5Blist%20-e%20-json%20-compiled=true%20-test=true%20-export=false%20-deps=true%20-find=false%20--%20/Users/john/git/bitfield/exercism/users/bcc32/go/paasio%5D: ToUTF16Column: missing content
[Error - 10:13:06] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio_test.go
  Code: 0 
[Error - 10:13:06] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio_test.go
  Code: 0 
[Error - 10:13:06] Request textDocument/hover failed.
  Message: no AST for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio_test.go
  Code: 0 
[Error - 10:13:08] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 10:13:08] unable to read file /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: open /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: no such file or directory
[Error - 10:13:08] unable to read file /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: open /Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- /Users/john/git/bitfield/exercism/users/bcc32/go/paasio]: no such file or directory
[Error - 10:13:08] failed to deliver diagnostic for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/go%20%5Blist%20-e%20-json%20-compiled=true%20-test=true%20-export=false%20-deps=true%20-find=false%20--%20/Users/john/git/bitfield/exercism/users/bcc32/go/paasio%5D: ToUTF16Column: missing content
[Error - 10:13:08] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 10:13:08] Request textDocument/codeAction failed.
  Message: no token file for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 10:13:09] Request textDocument/hover failed.
  Message: no AST for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 10:13:11] Request textDocument/hover failed.
  Message: no AST for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 
[Error - 10:13:13] Request textDocument/hover failed.
  Message: no AST for file:///Users/john/git/bitfield/exercism/users/bcc32/go/paasio/paasio.go
  Code: 0 

(The issue you mentioned was slightly hijacked by someone else who posted a different problem, which was then fixed and the issue closed!)

@bcmills bcmills removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 21, 2019
@stamblerre
Copy link
Contributor

I'm not sure how this code would be compiling, because you need to either be in your $GOPATH or you will need to be using modules with a go.mod file. gopls will not work correctly outside of $GOPATH without a go.mod file.

@bcmills
Copy link
Contributor

bcmills commented May 21, 2019

@stamblerre , the code could compile in GOPATH mode if its only imports are provided by GOPATH/src and the standard library.

@stamblerre
Copy link
Contributor

Thanks @bcmills - I was able to repro the behavior. It does seem that go build and go list would work when you are actually inside the directory. However, gopls relies on go list on an absolute path, which doesn't work in this case.

@bitfield: I think the conclusion here is that you will either need to be in your $GOPATH, or you will need to run go mod init in the directory.

@evandigby
Copy link

Since this is expected behavior does it make sense to clarify the error message? This issue could be rephrased as “error message unclear when doing this unsupported thing” but it almost certainly will come up again if the error isn’t clarified.

@stamblerre
Copy link
Contributor

I added a bit of extra logging to log errors when we try to type-check a package (https://golang.org/cl/178277). However, we are really limited by the error quality of go list. If go list doesn't return a detailed error, than we have no way of understanding why exactly it failed.

@bitfield
Copy link
Author

Thanks!

@golang golang locked and limited conversation to collaborators May 22, 2020
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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants