Closed golfxiao closed 1 year ago
Hmm, it looks like os.Executable()
is failing from the gopls binary.
Do you have any idea why that may be the case? Could you write a small Go program to see if it reproduces? E.g.: https://go.dev/play/p/ZVqeBuju87z
I don't understand why you typing this problem as WaitingForInfo status, but what's missing?
Are Findleyr's comments above talking to me? The output path of the os.Executable() function is my GoPath path: /Users/a200007/work/ucgit/golang.
Hmm, it looks like
os.Executable()
is failing from the gopls binary.Do you have any idea why that may be the case? Could you write a small Go program to see if it reproduces? E.g.: https://go.dev/play/p/ZVqeBuju87z
/Users/a200007/work/ucgit/golang/
Thanks @golfxiao. Since it sounds like linking isn't broken, would you try reinstalling gopls? go install golang.org/x/tools/gopls@latest
?
If that doesn't work, as a temporary fix you can install a version of gopls that didn't depend on access to os.Executable()
: go install golang.org/x/tools/gopls@v0.11.0
.
Thanks @finkleyr. The older version of gopls, v0.11.0, is working. I will temporarily use this version for now.
Description: When the "Use Language Server" option is enabled in VS Code with the vscode-go extension, importing dependencies managed by go mod results in an error. The error message suggests a failure to read cache data for the imported package and indicates a problem with hashing the gopls executable.
Steps to Reproduce:
Open VS Code with the vscode-go extension installed. Enable the "Use Language Server" option in the settings. Create a Go module that depends on external packages managed by go mod, such as gnetis.com/golang/core/golib/uac. Import the package in a Go source file. Expected Behavior: The imported package should be recognized and imported without any errors or issues.
Actual Behavior: The following error message is displayed:
📋 Copy code could not import gnetis.com/golang/core/golib/uac (failed to read cache data for gnetis.com/golang/core/golib/uac: can't hash gopls executable: cannot find executable path)compilerBrokenImport Additional Information:
This issue occurs consistently when the "Use Language Server" option is enabled. Disabling the "Use Language Server" option resolves the import error. The go get and go build commands work correctly with the same dependencies.
What version of Go, VS Code & VS Code Go extension are you using?
Go: Locate Configured Go Tools
command output: GO111MODULE="auto" GOARCH="amd64" GOBIN="/Users/a200007/work/ucgit/golang/bin" GOCACHE="/Users/a200007/Library/Caches/go-build" GOENV="/Users/a200007/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/a200007/work/ucgit/golang/pkg/mod" GONOPROXY="" GONOSUMDB="bjgitlab.gnetis.com" GOOS="darwin" GOPATH="/Users/a200007/work/ucgit/golang" GOPRIVATE="" GOPROXY="http://192.168.24.11:3000,https://mirrors.aliyun.com/goproxy/,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.google.cn" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="0" GOMOD="/Users/a200007/work/ucgit/golang/confspaceserver/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cp/7qks5zmd671fgcm7y5_8ym700000gn/T/go-build4100417456=/tmp/go-build -gno-record-gcc-switches -fno-common"Share the Go related settings you have added/edited
{ "typescript.useCodeSnippetsOnMethodSuggest": true, "files.autoSave": "onFocusChange", "python.disablePromptForFeatures": [ "pylint" ], "go.testFlags": [ "-v" ], "extensions.ignoreRecommendations": true, "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true }, "go.formatTool": "goimports", "[go]": { "editor.snippetSuggestions": "none", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true, } }, "gopls": { "usePlaceholders": true, // add parameter placeholders when completing a function // Experimental settings "completeUnimported": true, // autocomplete unimported packages "deepCompletion": true, // enable deep completion }, "files.eol": "\n", "go.toolsManagement.autoUpdate": true, "go.toolsGopath": "/Users/a200007/work/ucgit/golang", "explorer.confirmDelete": false, "search.followSymlinks": false, "files.exclude": { "/.git": true, "/.svn": true, "/.hg": true, "/CVS": true, "/.DS_Store": true, "/tmp": true, "/node_modules": true, "/bower_components": true, "/dist": true }, "files.watcherExclude": { "/.git/objects/": true, "/.git/subtree-cache/": true, "/node_modules/": true, "/tmp/": true, "/bower_components/": true, "/dist/*": true }, "editor.fontSize": 14, "security.workspace.trust.untrustedFiles": "open", "editor.largeFileOptimizations": false, "dart.flutterSdkPath": "/Users/a200007/work/software/flutter", "http.proxyAuthorization": null, "workbench.colorTheme": "Default Light+", "vscodeGoogleTranslate.preferredLanguage": "Chinese (Simplified)", "github.copilot.advanced": {}, "[python]": { "editor.formatOnType": true }, "codeium.enableSearch": true, "codeium.enableConfig": { "": true }, "go.languageServerFlags": [ "-rpc.trace" ] }