-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gopls
caching error when updating go version
#8071
Comments
I like that! I think that's also orthogonal to the rest of what's discussed in #7902. Just to challenge the idea though: what are the downsides of that? For example, yesterday we found out that |
Yes, this is a good point! However, I think we already have this problem every time a new version of Every time Zed does not find the correct binary in This does not interfere with #7902 and would solve the bug. If you are happy with the proposed solution, I would love to implement it myself and create a PR? |
I am happy with the proposed solution, BUT we're also right now heavily discussing how we want to proceed with language extensions and (btw. Grüße aus Nähe Aschaffenburg nach Darmstadt! Sorry, couldn't resist!) |
Yes of course! Sounds good to me. (Haha Grüße zurück!) |
Just to record this here, because I just ran into the code: we do cleanup other binaries in our folder zed/crates/zed/src/languages/go.rs Lines 121 to 124 in dfcf72b
|
Glad to hear, @nilskch! |
I just got to this issue because I recently installed Go 1.23 and just tried to use an iterator for the first time. Zed (v0.160.7) and gopls (v0.15.3) complain that I cannot range over an iterator function. gopls is out of date, v0.16.2 is current. I ended up doing I did just check my Zed/languages/gopls directory:
Should Zed have done something special so that I wouldn't see the error? I don't quite follow what this issue and the accompanying PR accomplished. |
Oh yes you are right, #8188 only checks for
Would you accept a PR with the proposed caching solution now? |
Wait, I'm not sure I follow — |
it was built with the wrong go version. the go version you build |
this looks like something is wrong with the cleanup logic as well :/ |
Alright, that makes sense. Yeah, in that case we should probably overhaul our caching logic. |
#20922 implements the proposed solution of caching the go version as well |
Closes #8071 Release Notes: - Changed the Go integration to check whether an existing `gopls` was compiled for the current `go` version. Previously we cached gopls (the go language server) as a file called `gopls_{GOPLS_VERSION}`. The go version that gopls was built with is crucial, so we need to cache the go version as well. It's actually super interesting and very clever; gopls uses go to parse the AST and do all the analyzation etc. Go exposes its internals in its standard lib (`go/parser`, `go/types`, ...), which gopls uses to analyze the user code. So if there is a new go release that contains new syntax/features/etc. (the libraries `go/parser`, `go/types`, ... change), we can rebuild the same version of `gopls` with the new version of go (with the updated `go/xxx` libraries) to support the new language features. We had some issues around that (e.g., range over integers introduced in go1.22, or custom iterators in go1.23) where we never updated gopls, because we were on the latest gopls version, but built with an old go version. After this PR gopls will be cached under the name `gopls_{GOPLS_VERSION}_go_{GO_VERSION}`. Most users do not see this issue anymore, because after #8188 we first check if we can find gopls in the PATH before downloading and caching gopls, but the issue still exists.
Check for existing issues
Describe the bug / provide steps to reproduce it
First of all, thank you very much for this awesome IDE! I am just getting started using Zed but I already love it!
As discussed with @mrnugget in #7902, I opened this Issue.
I installed the new go version (
go1.22.0
), and I rango install golang.org/x/tools/gopls@latest
to buildgopls
with the newest go version on my system. In VSCode, everything works andgopls
supports the new language features, but not Zed. Zed installedgopls
when I had an older version of go installed and cached it in~/Library/Application\ Support/Zed/languages/gopls/gopls_0.14.2
.0.14.2
is the newest version ofgopls
, but it was not installed using the newest version of go and, therefore, does not support the newest language features (in my case, it was iterating over integersfor i := range 10
). If you install a new version of go, you must rungo install golang.org/x/tools/gopls@latest
again using the new version, which Zed didn't.Deleting
~/Library/Application\ Support/Zed/languages/gopls/gopls_0.14.2
forces Zed to reinstallgopls
using the new version of go and everything works.One solution would be to cache
gopls
differently: Instead of naming the cached filegopls_{GOPLS_VERSION}
(see here or here), we could cache it like this:gopls_{GOPLS_VERSION}_{GO_VERSION}
. By doing that, we also cache with which go versiongopls
was built. Changing/Updating the go version then triggers a newgopls
installation.Checking if a globally available version of
gopls
is available would also be a nice idea and is somewhat related to this issue (See #7902 for more details).Environment
Zed: v0.122.2 (Zed)
OS: macOS 14.2.1
Memory: 18 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.If you only need the most recent lines, you can run the
zed: open log
command palette action to see the last 1000.No response
The text was updated successfully, but these errors were encountered: