-
Notifications
You must be signed in to change notification settings - Fork 758
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
vscode-go sets GOFLAGS, breaking go modules #1595
Comments
I am not able to reproduce this. I would not expect Can you please share your language server logs? Information on how to capture them can be found here. |
Sure:
|
Hm yeah does look like GOFLAGS is in there. Are you sure that those are your full VS Code settings--is it possible that you also have workspace specific settings? |
I checked that, yeah - workspace settings are empty except for the gopls settings I just added:
|
What is the output of |
I get this when working with any go repo that is a module, and doesn't vendor dependencies. |
And just to confirm, when you are in a regular terminal and |
Correct. This is from the terminal that launched vscode:
|
Thanks for confirming. This is stumping me a bit, since there shouldn't be a place where the extension manipulates the value of |
The go extension inherits the environment variables VS Code sees. Can you check if the VS Code is launched with clean environment variables setting, and if not, make sure to start vscode from the clean environment? (e.g. shell without the GOFLAGS environment variable set, and also make sure the GOENV file (e.g. "/home/geoff/.config/go/env") is empty, ...) You can inspect the environment variables VS Code sees from Developer Tools (Command palette -> "Developers: Toggle Developer Tools" and querying The extension itself doesn't |
After a little poking around, I have a little more information about this. Yes, I'm launching vscode from a terminal without goflags set. The problem happens when there's more than one instance of vscode running. I normally have an instance of vscode running with a project open that DOES have GOFLAGS set. I'm using Once my first instance of vscode is running, if I start a new terminal, So it appears that the new vscode instance is getting at least some of its envars from the running instance. That might be expected behavior, but it comes as a surprise to me. To reproduce this simply, create a pair of empty directories, like This means that this bug, if it is a bug, is in vscode itself, and not the go plugin. |
It looks like this is a duplicate of microsoft/vscode#15452 |
Removing gopls from setting.json did the trick for me. |
good to me, thanks! |
I already do this, but still the same |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls@v0.7.0 h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDfaYU=
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.507ce72a4466fbb27b715c3722558bb15afa9f48
x64
Go: Locate Configured Go Tools
command.Checking configured tools....
GOBIN: undefined
toolsGopath:
gopath: /home/geoff/go
GOROOT: /usr/lib/go
PATH: /usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/snap/bin:/home/geoff/bin:/home/geoff/.local/bin:/home/geoff/go/bin:/home/geoff/mygo/bin
gopkgs: /home/geoff/mygo/bin/gopkgs installed
go-outline: /home/geoff/mygo/bin/go-outline installed
gotests: /home/geoff/mygo/bin/gotests installed
gomodifytags: /home/geoff/mygo/bin/gomodifytags installed
impl: /home/geoff/mygo/bin/impl installed
goplay: /home/geoff/mygo/bin/goplay installed
dlv: /home/geoff/mygo/bin/dlv installed
dlv-dap: dlv-dap not installed
staticcheck: /home/geoff/mygo/bin/staticcheck installed
gopls: /home/geoff/mygo/bin/gopls installed
go env
Workspace Folder (go-libvirt): /home/geoff/do/go-libvirt
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/geoff/.cache/go-build"
GOENV="/home/geoff/.config/go/env"
GOEXE=""
GOFLAGS="-mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/geoff/go/pkg/mod"
GONOPROXY=".internal.digitalocean.com,github.com/digitalocean"
GONOSUMDB=".internal.digitalocean.com,github.com/digitalocean"
GOOS="linux"
GOPATH="/home/geoff/go"
GOPRIVATE="*.internal.digitalocean.com,github.com/digitalocean"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/home/geoff/do/go-libvirt/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1435964199=/tmp/go-build -gno-record-gcc-switches"
Share the Go related settings you have added/edited
{
"go.coverOnSave": true,
"go.coverOnSingleTest": true,
"go.autocompleteUnimportedPackages": true,
"go.testOnSave": true,
"go.useLanguageServer": true,
],
"go.coverageDecorator": {
"type": "highlight",
"coveredHighlightColor": "rgba(32,64,64,0.4)",
"uncoveredHighlightColor": "rgba(128,64,64,0.2)",
"coveredGutterStyle": "slashblue",
"uncoveredGutterStyle": "slashyellow"
},
"go.coverOnSingleTestFile": true,
"go.toolsEnvVars": {
},
"go.toolsManagement.autoUpdate": true,
}
Describe the bug
I work on some repos that are go modules, for example, https://github.com/digitalocean/go-libvirt.
If I launch vscode at the root of one of those repos, vscode throws an error from gopls: 'Inconsistent vendoring detected. Please re-run "go mode vendor".'
This happens because vscode-go has set
GOFLAGS=-mod=vendor
. It only does this if GOFLAGS is not set when vscode is started; if I launch vscode withGOFLAGS="" code
, all is well.This problem happens with any go module that doesn't use vendoring. You can observe it easily enough by launching from a shell with no GOFLAGS set, then running
echo $GOFLAGS
from vscode's built-in terminal.It's possible something in my environment is causing this, but I haven't found anything.
Steps to reproduce the behavior:
Clone https://github.com/digitalocean/go-libvirt
Ensure GOFLAGS is not set in your terminal.
Launch vscode in the go-libvirt project directory. You should get an "inconsistent vendoring" error.
Verify that GOFLAGS is set in vscode.
Exit and restart vscode with GOFLAGS="", the issue should be gone.
The text was updated successfully, but these errors were encountered: