I am trying to install Go tools in my VS Code editor and when I select the View, CMD, Install and select Go: Install/Update tools, I get this -> "command 'go.tools.install' not found" What am I doing wrong?
2 Answers
As seen in Microsoft/vscode-go issue 755:
For all guys who are stuck with command '
go.tools.install
' not found problem on Windows.Check if
%GOPATH%\bin
is in yourPATH
environment variable.
After half and an hour I finally figured out thatPATH
remains unchanged if you try to change it likeset PATH=%PATH%
.... You need explicitly change it in your system settings.
With recent Go installation, make sure GOROOT
reference your Go installation folder.
I also like to set go.goroot
to that folder in the settings of VSCode.
You don't need GOPATH
: it defaults to %USERPROFILE%\go
: make sure %USERPROFILE%\go\bin
is in your PATH, before launching VSCode.
- unzip go1.13.6.windows-amd64.zip anywhere (not in
%USERPROFILE%\go
, since it is reserved forGOPATH
) - set GOROOT to
C:\path\to\go
(where you just uncompressed the Go archive) - add
%GOROOT%\bin
to%PATH%
-
Added it to my PATH and got this: Failed to run "go env" to find GOPATH as the "go" binary cannot be found in either GOROOT(undefined) or PATH(C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Intuit\QBPOSSDKRuntime;C:\Program Files\Git\cmd;C:\Ruby24-x64\bin;C:\Users\family\AppData\Local\Programs\Microsoft VS Code\bin; C:\Users\family\go\bin) – DougHughes81 Jan 19 '20 at 02:12
-
@DougHughes81 Set in your user environment variable `GOROOT` to where Go is installed. And add `%GOROOT%\bin` to your path. Note: `C:\Users\family\go` is not `GOROOT`, it is the default value for `GOPATH`. – VonC Jan 19 '20 at 02:17
-
As in which of these paths? C:\Users\Family\AppData\Roaming\Code\User C:\Program Files\Git\bin\bash.exe Sorry for being so naive, but I am when it comes to Go – DougHughes81 Jan 19 '20 at 03:11
-
%USERPROFILE%\AppData\Roaming\Code\User...no \bin there – DougHughes81 Jan 19 '20 at 03:13
-
Simply unzip go wherever you want, and add that path + bin – VonC Jan 19 '20 at 04:07
-
Worked perfectly!! Thank you kind sir :) – DougHughes81 Jan 19 '20 at 04:34
In my case I was on Ubuntu and installed go using snap so I did the following:
Uninstall go from snap
sudo snap remove go
Download go from the original source:
https://go.dev/doc/install
Install go as recommended in the source e.g.:
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.1.linux-amd64.tar.gz
Run the following to add the environment variables in the
.bashrc
:
echo export GOROOT=/usr/local/go >> ~/.bashrc
echo export GOPATH=\$HOME/go >> ~/.bashrc
echo export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin >> ~/.bashrc
Note: Setting $GOROOT
variable is obsolete in recent versions as discussed here
Restart the VS Code to read the environment variables set above
In VSCode press
Ctrl+Shift+P
and run again theGO: Install/Update tools
, install everything selecting the checkboxes and you are good to GO!

- 2,246
- 3
- 33
- 29