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: no packages returned: packages.Load error #42353

Closed
meakkineni opened this issue Nov 3, 2020 · 4 comments
Closed

x/tools/gopls: no packages returned: packages.Load error #42353

meakkineni opened this issue Nov 3, 2020 · 4 comments

Comments

@meakkineni
Copy link

@meakkineni meakkineni commented Nov 3, 2020

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

$ go version go1.15.3 darwin/amd64

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="/Users/mac/Library/Caches/go-build"
GOENV="/Users/mac/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mac/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mac/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mac/Documents/projects/myproject/test.com/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/mv/k0x9_cgs6mb7jqwstkwg1y9c0000gq/T/go-build174474178=/tmp/go-build -gno-record-gcc-switches -fno-common"
gopls trace Output
$ gopls -rpc.trace -v check main.go
gopls -rpc.trace -v check main.go
2020/11/02 22:37:16 Info:2020/11/02 22:37:16 go env for /Users/mac/Documents/projects/myproject/test.com
(root /Users/mac/Documents/projects/myproject/test.com)
(go version go version go1.15.3 darwin/amd64)
(valid build configuration = true)
(build flags: [])
GOPATH=/Users/mac/go
GOPRIVATE=
GOPROXY=https://proxy.golang.org,direct
GOMODCACHE=/Users/mac/go/pkg/mod
GONOPROXY=
GOSUMDB=sum.golang.org
GOCACHE=/Users/mac/Library/Caches/go-build
GONOSUMDB=
GOINSECURE=
GOROOT=/usr/local/go
GO111MODULE=on
GOMOD=/Users/mac/Documents/projects/myproject/test.com/go.mod
GOFLAGS=

2020/11/02 22:37:17 Info:2020/11/02 22:37:17 go/packages.Load
snapshot=0
directory=/Users/mac/Documents/projects/myproject/test.com
query=[builtin test.com/...]
packages=1
2020/11/02 22:37:17 Info:2020/11/02 22:37:17 go/packages.Load
snapshot=0
package_path="command-line-arguments"
files=[]
2020/11/02 22:37:17 Info:2020/11/02 22:37:17 go/packages.Load
snapshot=1
directory=/Users/mac/Documents/projects/myproject/test.com
query=[file=/Users/mac/Documents/projects/myproject/test.com/main.go]
packages=0
2020/11/02 22:37:17 Error:2020/11/02 22:37:17 reloadOrphanedFiles: failed to load: no packages returned: packages.Load error
query=[file:///Users/mac/Documents/projects/myproject/test.com/main.go]

What did you do?

I am trying to go to the definition of a function. For instance fmt.Println().
I use vim-go
I put the cursor under Println and try to go the definition and I get the below error
The same thing works when I change my definition server to 'guru'

Doesn't work either for user defined functions or for standard package functions

What did you expect to see?

Expected to see the definition of the function

What did you see instead?

no packages returned: packages.Load error

@toothrot toothrot changed the title Error on trying to find definition - "no packages returned: packages.Load error" x/tools/gopls: Error on trying to find definition - "no packages returned: packages.Load error" Nov 3, 2020
@gopherbot gopherbot added this to the Unreleased milestone Nov 3, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/vscode-go Nov 4, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Nov 4, 2020

What is the output of go list -e -json -compiled ./... when you are in the /Users/mac/Documents/projects/myproject/test.com directory?

@meakkineni
Copy link
Author

@meakkineni meakkineni commented Nov 4, 2020

Hi @stamblerre thanks for responding. This is what I see

$ go list -e -json -compiled ./...

go build internal/unsafeheader: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/c0/c0e94ba9040544ec35c16499ee2905975dd7ec6b24e473a66a3aa2ec46e5f846-a: no such file or directory
go build unicode: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/f1/f119670a773db65c0815a7827d762943142c014aeb48566d2b9eaa52f9903efb-a: no such file or directory
go build unicode/utf8: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/95/9515ad0b3f4f5f63d1c4bbe8c238ad1345865fcc6118479bfddeec955a538a18-a: no such file or directory
go build internal/race: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/97/97a4861b18817b8085b8685e54051446a4204c01b709430231b4257afa1f25cc-a: no such file or directory
go build math/bits: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/1b/1b3caccfa06a6e29b2c6bdc528ffc5e7712931e997cb30d477c31e31f2a5dbee-a: no such file or directory
go build runtime/internal/sys: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/29/29773ae629eba8ce238a7697425861a0be9c007b61408c0172f688f609ded2d0-a: no such file or directory
go build internal/cpu: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/8c/8ca5bd8bd1572a5fecff05df9eeedf7d13b6c23a1320d5373a756df8d645e259-a: no such file or directory
go build runtime/internal/atomic: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/51/51a0ab315d5778b2f56dbc221a7220e3d1e24940a9424be9f5e4bd07e321b94b-a: no such file or directory
go build sync/atomic: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/mac/Library/Caches/go-build/f7/f76980501818889a818e399f49f4438edc3b14656a4616df4853c031cee3aa0d-a: no such file or directory
{
	"Dir": "/Users/mac/Documents/projects/myproject/test.com",
	"ImportPath": "test.com",
	"Name": "main",
	"Target": "/Users/mac/go/bin/test.com",
	"Root": "/Users/mac/Documents/projects/myproject/test.com",
	"Module": {
		"Path": "test.com",
		"Main": true,
		"Dir": "/Users/mac/Documents/projects/myproject/test.com",
		"GoMod": "/Users/mac/Documents/projects/myproject/test.com/go.mod",
		"GoVersion": "1.15"
	},
	"Match": [
		"./..."
	],
	"GoFiles": [
		"main.go"
	],
	"Imports": [
		"fmt"
	],
	"Deps": [
		"errors",
		"fmt",
		"internal/bytealg",
		"internal/cpu",
		"internal/fmtsort",
		"internal/oserror",
		"internal/poll",
		"internal/race",
		"internal/reflectlite",
		"internal/syscall/execenv",
		"internal/syscall/unix",
		"internal/testlog",
		"internal/unsafeheader",
		"io",
		"math",
		"math/bits",
		"os",
		"reflect",
		"runtime",
		"runtime/internal/atomic",
		"runtime/internal/math",
		"runtime/internal/sys",
		"sort",
		"strconv",
		"sync",
		"sync/atomic",
		"syscall",
		"time",
		"unicode",
		"unicode/utf8",
		"unsafe"
	]
}
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Nov 4, 2020

Thanks for sharing that output. My guess is that the issue is caused by the issues with the cache entries. Can you try running go clean -cache and then running the command again?

/cc @matloob @jayconrod @bcmills for further advice, especially since it seems like go/packages failed to pick up any packages with these error messages present

@stamblerre stamblerre changed the title x/tools/gopls: Error on trying to find definition - "no packages returned: packages.Load error" x/tools/gopls: no packages returned: packages.Load error Nov 4, 2020
@meakkineni
Copy link
Author

@meakkineni meakkineni commented Nov 4, 2020

Yay!! I figured out what issue was

After I did go clean -cache and tried to build my app, it failed with the message

failed to initialize build cache at /Users/mac/Library/Caches/go-build: mkdir /Users/mac/Library/Caches/go-build/00: permission denied

After digging a bit I realized that go-build folder has root as its owner instead of $USER. I changed the owner to current user with the command sudo chown -R $USER ~/Library/Caches/go-build.

Now, everything works fine.

Thank you @stamblerre for your help!!

@meakkineni meakkineni closed this Nov 4, 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
4 participants
You can’t perform that action at this time.