sublimelsp / LSP-gopls

Golang support for Sublime's LSP plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: go binary not found in $PATH

ucomru opened this issue · comments

commented

Good day!

With Package Control: Install Package I installed LSP and LSP-gopls

My System inf:

  • Mac OS M1, Ventura 13.4.1 (22F82)
  • Sublime Text build 4143
  • where go : /opt/homebrew/bin/go
  • go version : go1.20.4 darwin/arm64

But I get error:

Failed to start gopls - disabling for this window for the duration of the current session.
Re-enable by running "LSP: Enable Language Server In Project" from the Command Palette.

--- Error: ---
go binary not found in $PATH
screnn_part

I think its need to set home-brew bin path: PATH='/opt/homebrew/bin/'
I've trying to set it with LSP-gopls or with LSP.sublime settings files:

  1. LSP-gopls.sublime-settings:
{
    "gopls.env": {
        "PATH": "/opt/homebrew/bin",
        "GOPATH": "/Users/t/.go"
    }
}
  1. LSP.sublime-settings:
{
    "clients": {
        "gopls": {
            "env": {
                "PATH": "/opt/homebrew/bin",
                "GOPATH": "/Users/t/.go"
            },
            "enabled": true,
            "command": ["gopls"]
        }
    }
}

But the error steel present.

Help me please to solve this mistake. 🙏

commented

Many thanks!!!

The right way with MacOS + brew are add to the .zprofile :

export PATH=/opt/homebrew/bin:$PATH

And reboot os...

commented

Set $PATH in the .zprofile

Note that you don’t need that client configuration in LSP.sublime-settings, that’s what LSP-gopls provides. It also auto-downloads the gopls server binary. Basically I think if you remove all of your user config related to gopls and remove the server binary from homebrew it should still work.

Also, install LSP-json because I think you put the GOPATH setting in the wrong place.

commented

Note that you don’t need that client configuration in LSP.sublime-settings, that’s what LSP-gopls provides. It also auto-downloads the gopls server binary. Basically I think if you remove all of your user config related to gopls and remove the server binary from homebrew it should still work.

You're right!
GOPATH is the wrong way. But I tried to check all variations...
I assumed, that some one will be auto-downloads…
But, for the auto-download its need to find golfing using $PATH var.
$PATH in the .zprofile helped me, bin code auto-downloaded.
Other way, $PATH in the .zprofile need to run LSP server in the future.