Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve vs code - gopls command is not available

The "gopls" command is not available. Run "go get -v golang.org/x/tools/gopls" to install.

I'm running on go 1.14. Not sure what will happen, if I follow the instruction.

enter image description here


Installing 1 tool at the configured GOBIN: /usr/local/go/bin in module mode.
  gopls

Installing golang.org/x/tools/gopls FAILED
{
 "killed": false,
 "code": 1,
 "signal": null,
 "cmd": "/usr/local/go/bin/go get -v golang.org/x/tools/gopls",
 "stdout": "",
 "stderr": "go: downloading golang.org/x/tools/gopls v0.6.9\ngo: golang.org/x/tools/gopls upgrade => v0.6.9\ngo: downloading golang.org/x/tools v0.1.1-0.20210319172145-bda8f5cee399
...

1 tools failed to install.

gopls: failed to install gopls(golang.org/x/tools/gopls): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
go: downloading golang.org/x/tools/gopls v0.6.9
go: golang.org/x/tools/gopls upgrade => v0.6.9
go: downloading golang.org/x/tools v0.1.1-0.20210319172145-bda8f5cee399
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading honnef.co/go/tools v0.1.1
go: downloading golang.org/x/mod v0.4.1
golang.org/x/mod/semver
...

go get golang.org/x/tools/gopls: copying /var/folders/gq/bwl3jmx562x5twchgxvb6mlh0000gn/T/go-build703164122/b001/exe/a.out: open /usr/local/go/bin/gopls: permission denied
 no output 
like image 662
Nicole Avatar asked Mar 02 '26 01:03

Nicole


2 Answers

I had the same problem and solved it with:

go install -v golang.org/x/tools/gopls@latest

if you get the error:

x\[email protected]\internal\lsp\source\hover.go:23:2: module golang.org/x/text@latest found (v0.3.7), but does not contain package golang.org/x/text/unicode/runenames

try using:

go clean -modcache
go install -v golang.org/x/tools/gopls@latest
like image 123
Bas Avatar answered Mar 04 '26 16:03

Bas


The extension depends on other tools to provide necessary features. gopls is one of the core tools necessary to provide language features like code completion, navigation, search, etc for go language. See the list of tools the extension depends on: https://github.com/golang/vscode-go/blob/master/docs/tools.md

"Install" will install the 'gopls'. "Install All" will install all the missing tools.

If you are using go1.14, either click the button (or run "Go: Install/Update Tools" command from the command palette) or, install tools in module mode with the following command (not just go get because with go1.14, the go command will try to install the tool in GOPATH mode which isn't what you want.)

cd /tmp/
GO111MODULE=on go get golang.org/x/tools/gopls
like image 45
Hana Avatar answered Mar 04 '26 14:03

Hana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!