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

Tools (gopls, dlv) need recompiling to work with go version go1.22.5 darwin/arm64 #3637

Open
Viknet opened this issue Dec 23, 2024 · 5 comments · May be fixed by #3638
Open

Tools (gopls, dlv) need recompiling to work with go version go1.22.5 darwin/arm64 #3637

Viknet opened this issue Dec 23, 2024 · 5 comments · May be fixed by #3638
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@Viknet
Copy link

Viknet commented Dec 23, 2024

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.22.5 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
gopls, built in GOPATH mode (unknown)
    @
go: go1.22.5
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.96.1
42b266171e51a016313f47d0c48aca9295b9cbb2
arm64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.45.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Tools Configuration

Environment

GOBIN: undefined
toolsGopath:
gopath: /Users/viknet/go
GOROOT: /Users/viknet/.ya/tools/v4/6608868508
PATH: /Users/viknet/.ya/tools/v4/6608868508/bin:/Users/viknet/.n/bin:/Users/viknet/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:/Users/viknet/Library/Application Support/JetBrains/Toolbox/scripts:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/usr/local/munki:/Users/viknet/.cargo/bin
PATH (vscode launched with): /Users/viknet/.n/bin:/Users/viknet/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:/Users/viknet/Library/Application Support/JetBrains/Toolbox/scripts:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/usr/local/munki:/Users/viknet/.cargo/bin

Tools

go:	/Users/viknet/.ya/tools/v4/6608868508/bin/go: go version go1.22.5 darwin/arm64
gopls:	/Users/viknet/.ya/tools/v4/gopls-darwin-arm64/gopls	(version: unknown - /Users/viknet/.ya/tools/v4/gopls-darwin-arm64/gopls: go1.22.5)
gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/Users/viknet/.ya/tools/v4/6617165997/dlv	(version: unknown - /Users/viknet/.ya/tools/v4/6617165997/dlv: go1.22.5)
staticcheck:	/Users/viknet/go/bin/staticcheck	(version: v0.5.1 built with go: go1.22.5)

Go env

Workspace Folder (devtools/dummy_arcadia/cp): /Users/viknet/arcadia2/devtools/dummy_arcadia/cp

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/viknet/Library/Caches/go-build'
GOENV='/Users/viknet/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS='-mod=vendor'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/viknet/go/pkg/mod'
GONOPROXY='*.yandex-team.ru,*.yandexcloud.net'
GONOSUMDB='*.yandex-team.ru,*.yandexcloud.net'
GOOS='darwin'
GOPATH='/Users/viknet/go'
GOPRIVATE='*.yandex-team.ru,*.yandexcloud.net'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/viknet/.ya/tools/v4/6608868508'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/Users/viknet/.ya/tools/v4/6608868508/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='0'
GOMOD='/Users/viknet/arcadia2/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 arm64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/7p/lthc_cm90ps8kpq76hfnrpd8ytg_1j/T/go-build1546548798=/tmp/go-build -gno-record-gcc-switches -fno-common'

Share the Go related settings you have added/edited

        "go.toolsManagement.autoUpdate": false,
        "go.toolsManagement.checkForUpdates": "off",
        "go.goroot": "/Users/viknet/.ya/tools/v4/6608868508",
        "go.alternateTools": {
            "gopls": "/Users/viknet/.ya/tools/v4/gopls-darwin-arm64/gopls",
            "dlv": "/Users/viknet/.ya/tools/v4/6617165997/dlv"
        },

Describe the bug

We are using patched tools gopls and dlv built in GOPATH mode.

Tools version output in our case:

❯❯❯ /Users/viknet/.ya/tools/v4/6608868508/bin/go version -m /Users/viknet/.ya/tools/v4/gopls-darwin-arm64/gopls
/Users/viknet/.ya/tools/v4/gopls-darwin-arm64/gopls: go1.22.5

❯❯❯ /Users/viknet/.ya/tools/v4/6608868508/bin/go version -m /Users/viknet/.ya/tools/v4/6617165997/dlv
/Users/viknet/.ya/tools/v4/6617165997/dlv: go1.22.5

Due to the fact that the output consists of a single line, the calculation of the version fails at this line, and plugin shows warning message Tools (gopls, dlv) need recompiling to work with go version go1.22.5 darwin/arm64 every time workspace is loaded.

I'm proposing to change that line to

const moduleVersion = lines.length > 2 ? lines[2].split(/\s+/)[3] : "unknown";

With this patch I'm getting reasonable behavior:

Go: Locate Configured Go Tools

Tools Configuration

Environment

GOBIN: undefined
toolsGopath:
gopath: /Users/viknet/go
GOROOT: /Users/viknet/.ya/tools/v4/6608868508
PATH: /Users/viknet/.ya/tools/v4/6608868508/bin:/Users/viknet/.n/bin:/Users/viknet/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:/Users/viknet/Library/Application Support/JetBrains/Toolbox/scripts:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/usr/local/munki:/Users/viknet/.cargo/bin
PATH (vscode launched with): /Users/viknet/.n/bin:/Users/viknet/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:/Users/viknet/Library/Application Support/JetBrains/Toolbox/scripts:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/usr/local/munki:/Users/viknet/.cargo/bin

Tools

go:	/Users/viknet/.ya/tools/v4/6608868508/bin/go: go version go1.22.5 darwin/arm64

gopls:	/Users/viknet/.ya/tools/v4/gopls-darwin-arm64/gopls	(version: unknown built with go: go1.22.5)
gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/Users/viknet/.ya/tools/v4/6617165997/dlv	(version: unknown built with go: go1.22.5)
staticcheck:	/Users/viknet/go/bin/staticcheck	(version: v0.5.1 built with go: go1.22.5)

Go env

Workspace Folder (devtools/dummy_arcadia/cp): /Users/viknet/arcadia2/devtools/dummy_arcadia/cp

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/viknet/Library/Caches/go-build'
GOENV='/Users/viknet/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS='-mod=vendor'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/viknet/go/pkg/mod'
GONOPROXY='*.yandex-team.ru,*.yandexcloud.net'
GONOSUMDB='*.yandex-team.ru,*.yandexcloud.net'
GOOS='darwin'
GOPATH='/Users/viknet/go'
GOPRIVATE='*.yandex-team.ru,*.yandexcloud.net'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/viknet/.ya/tools/v4/6608868508'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/Users/viknet/.ya/tools/v4/6608868508/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='0'
GOMOD='/Users/viknet/arcadia2/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 arm64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/7p/lthc_cm90ps8kpq76hfnrpd8ytg_1j/T/go-build752033766=/tmp/go-build -gno-record-gcc-switches -fno-common'
@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/638475 mentions this issue: goInstallTools.ts: fix parsing version for tools built with GOPATH mode

@hyangah
Copy link
Contributor

hyangah commented Dec 23, 2024

Is there a reason that you need to build a tool in GOPATH mode? We require tools to be built in module mode.

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 23, 2024
@Viknet
Copy link
Author

Viknet commented Dec 23, 2024

@hyangah

Is there a reason that you need to build a tool in GOPATH mode?

Our entire codebase is organized as a large monorepository with dependencies by source code, not by modules. External dependencies are vendored under one root go.mod.
All tools are compiled or cross-compiled by our build system, which under the hood uses the native go build in GOPATH mode.

We require tools to be built in module mode.

I looked through the plugin code and didn't find any other places that would change the behavior with the returned moduleVersion == "unknown" from this function.

@hyangah
Copy link
Contributor

hyangah commented Jan 6, 2025

@Viknet It's ok to use Gopls or Delve built with go install to work with projects in a large monorepo. The tools version numbers are important for the extension to operate correctly, and tools version numbers are available in the binaries' build info only when they are built in module mode.

@Viknet
Copy link
Author

Viknet commented Jan 6, 2025

It's ok to use Gopls or Delve built with go install

It is not ok for us. There are several issues:

  1. x/tools and gopls require our patches to work with one-module monorepo.
    Making a local build will produce version (devel), which is useless for determining available features.
  2. Every tool dependency should be vendored locally, there is no internet access at building stage.
    Right now we have one global vendor directory for all projects. I don't know how to get it to work with module mode.
  3. Tools need to be compiled for every platform and delivered to developers environments.
    Our build system is taking care of it. Building alternative CI/CD pipeline just for this 2 tools is a huge overkill.

Overall, I'm only concerned about the useless warning which is popping on every workspace load. The button "Update tools" does nothing when go.alternateTools are set.

I could suggest other ways to fix this:

  1. Do not suggest to update tools from go.alternateTools.
  2. Change the way listOutdatedTools is getting Go version with which the tool was built. It does not use tool module version.
  3. Make an extension setting to disable this suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants