vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Auto-complete not working ("packages.Load error: unexpected end of JSON input")

Open kylepl opened this issue 4 months ago • 2 comments

Please answer these questions before submitting your issue. Thanks! -->

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.23.3 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info (note that this did not return when running gopls from vscode terminal, but ~/go/bin/gopls -v version did. I also see gopls running with VS code settings on my systems, and the other logs, so I'm not concerned it is not being found.

golang.org/x/tools/gopls v0.19.1 golang.org/x/tools/[email protected] h1:Yodhp3rnpnag60lVZrYPYbGMxTlTCIAj/B2Rv7AKuhA= github.com/BurntSushi/[email protected] h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= github.com/fatih/[email protected] h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/[email protected] h1:dDSgAjoOMp8da3egfz0t2S+t8RGOpEmEXZubcGuc0Bg= github.com/fatih/[email protected] h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= golang.org/x/exp/[email protected] h1:Br3+0EZZohShrmVVc85znGpxw7Ca8hsUJlrdT/JQGw8= golang.org/x/[email protected] h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= golang.org/x/[email protected] h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= golang.org/x/[email protected] h1:RXY2+rSHXvxO2Y+gKrPjYVaEoGOqh3VEXFhnWAt1Irg= golang.org/x/[email protected] h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= golang.org/x/[email protected] h1:XnjOegqwH6kBJoae6InSGbIFPHcLtUT/Eq8HjrZKbmQ= golang.org/x/[email protected] h1:Ju8QsuyhX3Hk8ma3CesTbO8vfJD9EvUBgHvkxHBzj0I= honnef.co/go/[email protected] h1:fj8r9irJSpolAGUdZBxJIRY3lLc4jH2Dt4lwnWyWwpw= mvdan.cc/[email protected] h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= mvdan.cc/xurls/[email protected] h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI= go: go1.24.4

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.96.2 fabdb6a30b49f79a7aba0f2ad9df9b399473380f x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.48.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • Tools Configuration

Environment

GOBIN: undefined toolsGopath: gopath: /home/kyle/go GOROOT: /home/kyle/repos/monorepo/bazel-monorepo/external/rules_go++go_sdk+main___download_0/ PATH: /home/kyle/repos/monorepo/bazel-monorepo/external/rules_go++go_sdk+main___download_0/bin:/home/kyle/bin:/home/kyle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/kyle/bin PATH (vscode launched with): /home/kyle/bin:/home/kyle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/kyle/bin

Tools

go:	/home/kyle/repos/monorepo/bazel-monorepo/external/rules_go++go_sdk+main___download_0/bin/go: go version go1.23.3 linux/amd64

gopls:	/home/kyle/go/bin/gopls	(version: v0.19.1 built with go: go1.24.4)
gotests:	not installed
impl:	not installed
goplay:	not installed
dlv:	not installed
staticcheck:	/home/kyle/go/bin/staticcheck	(version: v0.6.0 built with go: go1.24.0)

Go env

Workspace Folder (monorepo): /home/kyle/repos/monorepo

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/kyle/.cache/go-build'
GOENV='/home/kyle/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/kyle/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/kyle/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/kyle/repos/monorepo/bazel-monorepo/external/rules_go++go_sdk+main___download_0/'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/kyle/repos/monorepo/bazel-monorepo/external/rules_go++go_sdk+main___download_0/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/kyle/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/kyle/repos/monorepo/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2843695244=/tmp/go-build -gno-record-gcc-switches'

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file. Share all the settings with the go. or ["go"] or gopls prefixes.

"go.goroot": "${workspaceFolder}/bazel-${workspaceFolderBasename}/external/rules_go++go_sdk+main___download_0/",
  "go.toolsEnvVars": {
    "GOPACKAGESDRIVER": "${workspaceFolder}/whyle/toolchain/gopackagedrivers.sh"
  },
  "go.enableCodeLens": {
    "runtest": false
  },
  "gopls": {
    "build.directoryFilters": [
      "-bazel-bin",
      "-bazel-out",
      "-bazel-testlogs",
      "-bazel-monorepo",
    ],
    "formatting.gofumpt": true,
    "formatting.local": "whylelabs.ca/mod",
    "ui.completion.usePlaceholders": true,
    "ui.semanticTokens": true,
    "ui.codelenses": {
      "gc_details": false,
      "regenerate_cgo": false,
      "generate": false,
      "test": false,
      "tidy": false,
      "upgrade_dependency": false,
      "vendor": false
    },
  },
  "go.useLanguageServer": true,
  "go.buildOnSave": "off",
  "go.lintOnSave": "off",
  "go.vetOnSave": "off",
  "go.languageServerFlags": [
    "-rpc.trace"
  ]

Describe the bug

Normally, auto-complete and such work great (and has been for awhile, not clear what changed). Now I just see an error of "packages.Load error: unexpected end of JSON input" - constantly spinning at the bottom.

I expect auto-complete to work.

Steps to reproduce the behavior:

I am using Bazel (via https://github.com/bazel-contrib/rules_go). Everything was working fine in my repo, and I have not worked down to a minimum repro - but it occurs immediately on opening a Go file in VS code (unsurprisingly).

The error of "unexpected end of JSON" is quite opaque, I'm mainly looking for advice on how to see what output was returned, or anything else to get more detailed info to debug. It might be something related to Bazel, but this would help narrow it down.

I've attached a brief trace from adding -rpc.trace.

trace.txt

kylepl avatar Aug 05 '25 19:08 kylepl