Skip to content

Setting go.terminal.activateEnvironment setting to false does nothing #3943

@alexbrainman

Description

@alexbrainman

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.25.4 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
C:\Users\User\src\github.com>gopls -v version
'gopls' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\User\src\github.com>
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
C:\Users\User\src\go\src>code -v
1.107.0
618725e67565b290ba4da6fe2d29f8fa1d4e3622
x64

C:\Users\User\src\go\src>
  • Check your installed extensions to get the version of the VS Code Go extension
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: C:\Users\User\go
GOROOT: C:\Users\User\src\go1.25.4
PATH: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin

## Tools

	go:	C:\Users\User\src\go1.25.4\bin\go.exe: go version go1.25.4 windows/amd64

	gopls:	C:\Users\User\go\bin\gopls.exe	(version: v0.20.0 built with go: go1.26-devel_5241d114f5)
	gotests:	not installed
	impl:	not installed
	goplay:	not installed
	dlv:	not installed
	staticcheck:	C:\Users\User\go\bin\staticcheck.exe	(version: v0.6.1 built with go: go1.26-devel_5241d114f5)

## Go env

Workspace Folder (go): c:\Users\User\src\go

	set AR=ar
	set CC=gcc
	set CGO_CFLAGS=-O2 -g
	set CGO_CPPFLAGS=
	set CGO_CXXFLAGS=-O2 -g
	set CGO_ENABLED=0
	set CGO_FFLAGS=-O2 -g
	set CGO_LDFLAGS=-O2 -g
	set CXX=g++
	set GCCGO=gccgo
	set GO111MODULE=
	set GOAMD64=v1
	set GOARCH=amd64
	set GOAUTH=netrc
	set GOBIN=
	set GOCACHE=C:\Users\User\AppData\Local\go-build
	set GOCACHEPROG=
	set GODEBUG=
	set GOENV=C:\Users\User\AppData\Roaming\go\env
	set GOEXE=.exe
	set GOEXPERIMENT=
	set GOFIPS140=off
	set GOFLAGS=
	set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\User\AppData\Local\Temp\go-build360458620=/tmp/go-build -gno-record-gcc-switches
	set GOHOSTARCH=amd64
	set GOHOSTOS=windows
	set GOINSECURE=
	set GOMOD=NUL
	set GOMODCACHE=C:\Users\User\go\pkg\mod
	set GONOPROXY=
	set GONOSUMDB=
	set GOOS=windows
	set GOPATH=C:\Users\User\go
	set GOPRIVATE=
	set GOPROXY=https://proxy.golang.org,direct
	set GOROOT=C:\Users\User\src\go1.25.4
	set GOSUMDB=sum.golang.org
	set GOTELEMETRY=local
	set GOTELEMETRYDIR=C:\Users\User\AppData\Roaming\go\telemetry
	set GOTMPDIR=
	set GOTOOLCHAIN=auto
	set GOTOOLDIR=C:\Users\User\src\go1.25.4\pkg\tool\windows_amd64
	set GOVCS=
	set GOVERSION=go1.25.4
	set GOWORK=
	set PKG_CONFIG=pkg-config
	
Workspace Folder (github.com): c:\Users\User\src\github.com

	set AR=ar
	set CC=gcc
	set CGO_CFLAGS=-O2 -g
	set CGO_CPPFLAGS=
	set CGO_CXXFLAGS=-O2 -g
	set CGO_ENABLED=0
	set CGO_FFLAGS=-O2 -g
	set CGO_LDFLAGS=-O2 -g
	set CXX=g++
	set GCCGO=gccgo
	set GO111MODULE=
	set GOAMD64=v1
	set GOARCH=amd64
	set GOAUTH=netrc
	set GOBIN=
	set GOCACHE=C:\Users\User\AppData\Local\go-build
	set GOCACHEPROG=
	set GODEBUG=
	set GOENV=C:\Users\User\AppData\Roaming\go\env
	set GOEXE=.exe
	set GOEXPERIMENT=
	set GOFIPS140=off
	set GOFLAGS=
	set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\User\AppData\Local\Temp\go-build1172021910=/tmp/go-build -gno-record-gcc-switches
	set GOHOSTARCH=amd64
	set GOHOSTOS=windows
	set GOINSECURE=
	set GOMOD=NUL
	set GOMODCACHE=C:\Users\User\go\pkg\mod
	set GONOPROXY=
	set GONOSUMDB=
	set GOOS=windows
	set GOPATH=C:\Users\User\go
	set GOPRIVATE=
	set GOPROXY=https://proxy.golang.org,direct
	set GOROOT=C:\Users\User\src\go1.25.4
	set GOSUMDB=sum.golang.org
	set GOTELEMETRY=local
	set GOTELEMETRYDIR=C:\Users\User\AppData\Roaming\go\telemetry
	set GOTMPDIR=
	set GOTOOLCHAIN=auto
	set GOTOOLDIR=C:\Users\User\src\go1.25.4\pkg\tool\windows_amd64
	set GOVCS=
	set GOVERSION=go1.25.4
	set GOWORK=
	set PKG_CONFIG=pkg-config
	

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.delveConfig": {},
    "go.terminal.activateEnvironment": false,
    "go.logging.level": "verbose"
}

Describe the bug

I am trying to use go.terminal.activateEnvironment flag that I discovered in https://go-review.googlesource.com/c/vscode-go/+/336409 to prevent VS Code from adding my GOROOT value in front of my PATH.

Steps to reproduce the behavior:

  1. My go env command before starting VS Code outputs this:
C:\Users\User\src>go env
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\User\AppData\Local\Temp\go-build2284039207=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=NUL
set GOMODCACHE=C:\Users\User\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\User\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\User\src\go1.25.4
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\User\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\User\src\go1.25.4\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.25.4
set GOWORK=
set PKG_CONFIG=pkg-config

C:\Users\User\src>
  1. My echo %PATH% command outputs this before I start VS Code:
C:\Users\User\src> echo %PATH%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin

C:\Users\User\src
  1. I start VS Code by running code command.
  2. I start Command Prompt terminal. and I run echo %PATH% command inside terminal, and see this:
C:\Users\User\src\github.com>echo %PATH%
C:\Users\User\src\go1.25.4\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin

C:\Users\User\src\github.com>
  1. I expected the command in 5. to output the same output as in 3. But the output is different - this is my bug.

Screenshots or recordings

None.

Do you have any suggestions on how I can debug this problem?

Thank you.

Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions