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: file not found error #32603

Closed
glepnir opened this issue Jun 13, 2019 · 11 comments
Closed

x/tools/gopls: file not found error #32603

glepnir opened this issue Jun 13, 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

@glepnir
Copy link

glepnir commented Jun 13, 2019

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

$ go version
1.12.6

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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pendragon/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/pendragon/workstation"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/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/ct/5f1j4fl91mz_sdsl_3ksr5ph0000gp/T/go-build134162432=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Problem 1

  1. create a go mod project.
  2. touch a file .
  3. open the file
  4. got this error
[coc.nvim] Error output from languageserver.golang: failed to deliver diagnostic for file:///Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/
no%20packages%20found%20for%20/Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/server.go: stat /Users/pendragon/workstation/src/github.com/ta
igacute/rpcx/server/no packages found for /Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/server.go: no such file or directory

1

Problem 2

  1. input package name ,close file .
  2. reopen this file
  3. type a function . then input fmt.
  4. got nothing. and got a error
  Code: 0
[coc.nvim] Error output from languageserver.golang: Request textDocument/codeAction failed.
  Message: /Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/server.go:5:1: expected selector or type assertion, found '}' (and 1 more errors)

ranger

What did you expect to see?

works well

What did you see instead?

@gopherbot gopherbot added this to the Unreleased milestone Jun 13, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 13, 2019
@stamblerre
Copy link
Contributor

In the first case, it seems like gopls isn't able to stat the file. Are you sure it's saved on disk?
In the second case, the codeAction failure is that you are formatting a file with a syntax error. It's probably the job of your editor to handle these errors more gracefully, though I suppose we could also just not return errors if codeActions fail. For now, we don't support autocompletion of unimported packages (#31906).

@glepnir
Copy link
Author

glepnir commented Jun 13, 2019

first case : i used ranger file manager, used it to touch a file. i tested . its on disk.
second case : i can understood the codeaction error. but you can see the gif ,i didnt got any completion. this file i saved and reopend

@glepnir
Copy link
Author

glepnir commented Jun 13, 2019

i used coc and add this settings,does the usePlaceholders cant work in neovim ? i got a error [coc.nvim] Error output from languageserver.golang: method "DidChangeConfiguration" not yet implemented

            "golang": {
                "command": "gopls",
                "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
                "filetypes": [
                    "go"
                ],
                "settings": {
                    "gopls":{
                        "usePlaceholders": true
                    }
                }
            },

@stamblerre
Copy link
Contributor

For the first case, are you able to stat the file on your machine (stat /Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/server.go)? If gopls cannot see the file, then it will not be able to type-check it.

In the second case, you hadn't imported the fmt package. We do not yet support autocompletion for unimported packages (#31906).

Regarding the "usePlaceholders" setting - I am not sure what Vim supports, but I believe you will need to restart gopls when you modify these settings. We do not yet support changing configuration dynamically (#32258).

@stamblerre stamblerre changed the title x/tools/gopls: some errors. x/tools/gopls: some errors Jun 13, 2019
@glepnir
Copy link
Author

glepnir commented Jun 13, 2019

first case : i can confirm the file in my disk.
ranger
second case : the bingo branch that bingo author forked gopls can work with not import package . i think the gopls master achieve

@glepnir
Copy link
Author

glepnir commented Jun 13, 2019

i usually work in terminal with neovim . cause this #31542 , when i import a new package , i cant got the any completion , its very headache。i know its a known problem casue i create a issue about this.
hope the gopls can work well as soon as possible.

@stamblerre stamblerre changed the title x/tools/gopls: some errors x/tools/gopls: file not found error Jun 13, 2019
@stamblerre
Copy link
Contributor

After taking a deeper look at your error above, it seems like your file URI is being corrupted. It seems like gopls is trying to stat /Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/no packages found for /Users/pendragon/workstation/src/github.com/taigacute/rpcx/server/server.go, which obviously fails. I will investigate how that could be happening.

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 13, 2019
@gopherbot
Copy link

Change https://golang.org/cl/182460 mentions this issue: internal/lsp: parse filenames only out of go list errors

@jbrodriguez
Copy link

Thanks for looking into this @stamblerre, I'll test again as the fix becomes available.

@stamblerre
Copy link
Contributor

Thanks for reporting! If you pull the latest gopls, the fix should be available.

@jbrodriguez
Copy link

The 'phantom stat issue' is definitely solved 👍

[Info  - 3:28:47 PM] Build info
----------
version v0.1.0-cmd.gopls, built in $GOPATH mode

Go info
-------
go version go1.12.6 darwin/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johndoe/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/Home/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/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"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w9/7tlszcbs3msddknxvpp64gwc0000gn/T/go-build421060584=/tmp/go-build -gno-record-gcc-switches -fno-common"

[Error - 3:28:48 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:48 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:49 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:49 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:50 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:50 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:50 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:50 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Volumes/Home/code/unbalance/server/unbalance.go
  Code: 0 
[Error - 3:28:51 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:51 PM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: go/packages.Load: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 3:28:51 PM] Request textDocument/documentLink failed.
  Message: no AST for file:///Volumes/Home/code/unbalance/server/unbalance.go
  Code: 0 

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

4 participants