Open jacobbednarz opened 2 years ago
We really need to include more details about the installation failure.
Zed is basically running this command to install gopls
:
GO111MODULE=on GOBIN=~/.zed/gopls/gobin go install golang.org/x/tools/gopls@latest
mv ~/.zed/gopls/gobin/gopls ~/.zed/gopls/gopls_0.9.0
Other environment variables such as PATH
should be set up to match the parent shell environment (if you started Zed via the CLI) or the environment variables set on startup of your default shell (if you launched Zed from Finder).
If you get a chance, I'd be curious what output you get if you run that command manually.
running those two manually then opening zed .
works
$ GO111MODULE=on GOBIN=~/.zed/gopls/gobin go install golang.org/x/tools/gopls@latest
go: downloading golang.org/x/tools/gopls v0.9.0
go: downloading golang.org/x/tools v0.1.11
go: downloading golang.org/x/tools v0.1.12-0.20220630195555-6178576f8ba1
go: downloading honnef.co/go/tools v0.3.2
$ mv ~/.zed/gopls/gobin/gopls ~/.zed/gopls/gopls_0.9.0
$ zed .
another tidbit to include here is that my env has GOPROXY
unset for this directory, however, when firing up zed
, it thinks the value is GOPROXY=off
(which is my global). is this inheriting the env from somewhere globally as opposed to locally? that would explain why asdf-vm wasn't working too.
running those two manually then opening
zed .
works
Interesting, thanks for the update!
is this inheriting the env from somewhere globally as opposed to locally?
Actually yes; I was incorrect in my earlier comment. We currently always just load environment variables from your default login shell, as opposed to capturing the environment variables from the zed
CLI process.
So in this case, do you think GOPROXY
being set to off
was the reason for the installation failure?
if i'm following correctly, i think the GOPROXY=off
is a symptom of the larger issue of not loading the correct environment when calling zed .
. due to the environment not loading correctly, go
and gopls
weren't detected (even though both were installed via asdf-vm) and subsequently, the environment variables were incorrect.
I see, so go
would not be on your PATH
without detecting the environment from the shell that called zed
?
correct. as asdf-vm
is responsible for loading/unloading the environment ($PATH, $GO..), if i have a project specific version and launch zed
from inside that directory, it won't have the correct paths resulting in binaries missing.
does GOBIN
(from the commands above) ever pick up the value from the env if it is defined? reusing that may help here too if it doesn't already.
does
GOBIN
(from the commands above) ever pick up the value from the env if it is defined? reusing that may help here too if it doesn't already.
We currently always try to install language servers ourselves, rather than looking for existing binaries, but we could add logic for finding existing language servers on your system.
that would be rad; potentially save debugging version mismatches or why the language server in editor doesn't match the CLI invocation. will leave it up to you though š
thanks for the speedy support! you folks rock.
What's the workaround for this issue with zed 0.75.2
+?
Is there a way to connect to lsp server remotely? I am using docker development environment to keep my host clean, so I can't install gopls on host machine. I am currently trying to install gopls into container and somehow trick zed to use it via docker volumes, but no luck so far. Also I guess there could be option to specify remote flag in lsp config in settings, but I believe it still would require existence of gopls on host system.
@zlpkhr this isn't possible right now. Feel free to upvote
gopls is not compatible with golang version before 1.16. try upgrading golang first, it works for me
Before you begin Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a
+1
(š) on it.Describe the bug
When opening a Golang file, I encounter the following error.
Language server error: Go failed to install gopls. Is go installed?
To reproduce
- Use asdf-vm to install Go
- Ensure it is correctly setup
- Attempt to open a Golang file
- See error reported
Expected behavior
- Go file opens and
gopls
can be installed (or use the existing one on my $PATHScreenshots If applicable, add screenshots to help explain your problem.
Environment:
Zed 0.45.0 ā /Applications/Zed.app macOS 12.4 architecture x86_64
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/jacob/Library/Caches/go-build" GOENV="/Users/jacob/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/jacob/.asdf/installs/golang/1.17.9/packages/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/jacob/.asdf/installs/golang/1.17.9/packages" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/Users/jacob/.asdf/installs/golang/1.17.9/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/jacob/.asdf/installs/golang/1.17.9/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.17.9" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/jacob/go/src/github.com/cloudflare/cloudflare-go/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/36/zlscnhfn27n1yxx52cr1kdmr0000gp/T/go-build632993627=/tmp/go-build -gno-record-gcc-switches -fno-common"
$ which go gopls /Users/jacob/.asdf/shims/go /Users/jacob/.asdf/shims/gopls
Is there a way I can manually work around this in the meantime? Either by downloading the language server manually or forcing it in? Docs state Go isn't yet supported but the invite email said it was so unsure if this is still in progress.
gopls is not compatible with golang version before 1.16. try upgrading golang first, it works for me
@coooold i think you may have misread here. the go version used in this example is 1.17 so gopls is definitely available.
I'll share my solution. Today, I downloaded support for Rust and Go programming language server. The Rust setup didn't work initially, but after using "workspace restart", Rust started working.
As for Go, I struggled with it for at least 20 attempts, going back and forth with the issue. Finally, by chance, it worked.
I performed the following steps:
// Navigated to the directory:
cd ~/Library/Application\ Support/Zed/languages
// Removed the gopls directory:
rm -dr gopls
// command + shift + p, and search restart
run "workspace restart"
After following these steps, Go started working successfully. If you encounter permission issues, you can use sudo zed {your-go-project} and then follow the same steps mentioned above.
I didn't encounter any permissions issue but the sudo zed .
fixed the issue for me. Thanks @springzero
MacOS 11.6.2 (20G314) Zed 0.106.2
I encountered a similar issue where Zed couldn't find the "go" command when starting. This might be due to Zed not having access to the complete $PATH. To resolve my issue, I used the following approach:
create a openzed.app from Automator (Run Shell Script)
source ~/.zshrc && zed
open openzed.app
Can confirm these were still necessary w/ Zed 0.110.2
At this point, gopls is 0.14.2
$ GO111MODULE=on GOBIN=~/.zed/gopls/gobin go install golang.org/x/tools/gopls@latest
$ mv ~/.zed/gopls/gobin/gopls ~/.zed/gopls/gopls_0.14.1
$ zed .
Encountering the same issue. Running sudo zed .
in my application directory seemed to work. Any reason why sudo
is required to make it work?
Hey there š I'm pretty sure the issue you're having where you need to run Zed via sudo
is this issue where somehow the folder we install language servers into gets the wrong permissions:
This happens with go (and gopls) installed with brew as well:
which go gopls
/opt/homebrew/bin/go
/opt/homebrew/bin/gopls
Before you begin Check the backlog of issues to reduce the chances of creating duplicates; if an issue already exists, place a
+1
(š) on it.Describe the bug
When opening a Golang file, I encounter the following error.
To reproduce
Expected behavior
gopls
can be installed (or use the existing one on my $PATHScreenshots If applicable, add screenshots to help explain your problem.
Environment:
Zed 0.45.0 ā /Applications/Zed.app macOS 12.4 architecture x86_64
Is there a way I can manually work around this in the meantime? Either by downloading the language server manually or forcing it in? Docs state Go isn't yet supported but the invite email said it was so unsure if this is still in progress.