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: could not import xxxx (no package for import xxxx) #42828

Closed
wu0407 opened this issue Nov 25, 2020 · 10 comments
Closed

x/tools/gopls: could not import xxxx (no package for import xxxx) #42828

wu0407 opened this issue Nov 25, 2020 · 10 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@wu0407
Copy link

wu0407 commented Nov 25, 2020

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

$ go version
v1.15.5
gopls v0.5.3

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
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xiaoqing\AppData\Local\go-build
set GOENV=C:\Users\xiaoqing\AppData\Roaming\go\env  
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\git\kubernetes\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\xiaoqing\AppData\Local\Temp\go-build185837246=/tmp/go-build -gno-record-gcc-switches

What did you do?

use vscode 1.51.1 to open kubernets project, gopls report 115k+ problems

What did you expect to see?

no error

What did you see instead?

gopls server log output
gopls-server.txt

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Nov 25, 2020
@stamblerre
Copy link
Contributor

Can you please share your gopls settings (you can find them by opening the Command Palette with Ctrl+Shift+P and selecting "Preferences: Open Settings (JSON))? Also, can you please share a more verbose gopls log by adding -rpc.trace to your go.languageServerFlags configuration? More details here: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs.

@stamblerre stamblerre changed the title gopls could not import xxxx (no package for import xxxx x/tools/gopls: could not import xxxx (no package for import xxxx Nov 25, 2020
@stamblerre stamblerre changed the title x/tools/gopls: could not import xxxx (no package for import xxxx x/tools/gopls: could not import xxxx (no package for import xxxx) Nov 25, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 25, 2020
@gopherbot gopherbot added this to the Unreleased milestone Nov 25, 2020
@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 25, 2020
@wu0407
Copy link
Author

wu0407 commented Nov 26, 2020

gpls settings:

{
    "files.eol": "\n",
    "go.useCodeSnippetsOnFunctionSuggest": true,
    "editor.renderWhitespace": "all",
    "editor.renderControlCharacters": true,
    "files.autoSave": "afterDelay",
    "go.formatTool": "goimports",
    "workbench.activityBar.visible": true,
    "editor.minimap.enabled": false,
    "editor.wordWrap": "on",
    "go.toolsEnvVars": {
    //    "GOFLAGS": "-tags=linux"
    },
    "go.docsTool": "gogetdoc",
    "go.languageServerFlags": [


    
    ],
    "go.useLanguageServer": true,
    "go.languageServerExperimentalFeatures": {


        "diagnostics": true,
        "documentLink": true
    }
}

@wu0407
Copy link
Author

wu0407 commented Nov 26, 2020

pls server log with -rpc.trace option:
gopls-server-202011261057.txt

@wu0407
Copy link
Author

wu0407 commented Nov 29, 2020

the snapshot

@wu0407
Copy link
Author

wu0407 commented Nov 29, 2020

If disable the gopls server get the cannot find package "." in: D:\git\kubernetes\vendor\k8s.io\apimachinery\pkg\types
20201129123123

@wu0407
Copy link
Author

wu0407 commented Nov 29, 2020

find some error that couldn't run 'go': fork/exec C:\Program Files\Go\bin\go.exe: The filename or extension is too long. in the go.mod, and find like issue therecipe/qt#657 search by google .
so uninstall the tdm-gcc, it work on the 1.18.6 tag, but not work on master.
may be update go 1.13 to go 1.15 in go.mod from 1.18 to master

@wu0407
Copy link
Author

wu0407 commented Nov 29, 2020

gopls server log after uninstall tdm-gcc

gopls-server-uninstall-tdm-gcc.txt

@wu0407
Copy link
Author

wu0407 commented Nov 30, 2020

becuase go auto use vendor directory if the "go" version in the main module's go.mod file is
1.14 or higher, but vendor modules.txt not contain all dependence. so set to mod model vscode, it is resolve the ploblem.

   "go.toolsEnvVars": {
    "GOFLAGS": "-mod=mod"
    },

gopls-server log, related issue #39164

[Error - Received] 16:00:21.289 PM #21 source error list:
	file:///D:/git/kubernetes/go.mod:11:1-11:70: err: exit status 1: stderr: go: inconsistent vendoring in D:\git\kubernetes:
	bitbucket.org/bertimus9/systemstat@v0.0.0-20180207000608-0eeff89b0690: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/Azure/azure-sdk-for-go@v43.0.0+incompatible: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/Azure/go-autorest/autorest@v0.9.6: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/Azure/go-autorest/autorest/adal@v0.8.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/Azure/go-autorest/autorest/to@v0.2.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/GoogleCloudPlatform/k8s-cloud-provider@v0.0.0-20200415212048-7901bc822317: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/JeffAshton/win_pdh@v0.0.0-20161109143554-76bb4ee9f0ab: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

@stamblerre
Copy link
Contributor

I don't see the inconsistent vendoring error message in your previous log, but inconsistent vendoring will certainly cause problems. You should have seen a diagnostic message with a suggested fix to run go mod vendor, but in any case, I'm glad you were able to resolve the issue.

@stamblerre stamblerre removed this from the gopls/vscode-go milestone Nov 30, 2020
@wu0407
Copy link
Author

wu0407 commented Dec 1, 2020

yes, i don't reproduce inconsistent vendoring error message

@golang golang locked and limited conversation to collaborators Dec 1, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants