-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: reinitialize the workspace if the module directive changes #43186
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
Comments
Thanks for the report. We should treat a change to the module directive as something that forces a workspace reinitialization. |
@josharian: Can you share a repro case if you have one available? I saw you mentioned that you had one in your other issue. |
I don't understand precisely what happened here. I suppose a module, possibly a replace target, was renamed from github.com/tailscale to golang.zx2c4.com, and we still knew about old name, so tried to load it? And then it's a fork, so it causes a load failure without a replace? If I had to guess it's because we failed to clear out workspace packages when the module name changed. But I'm really not sure.
|
github.com/josharian/gopls-bug was what I wrote—change back and forth between the two commits. It doesn’t reproduce as easily in a small repo. You could also try GitHub.com/Tailscale/wireguard-go and switch back and forth between main and master branches. |
Thanks for the report. Was this the first time you had downloaded that repo and switched between those branches? I see two issues here: (1) The one @heschik described above--the module path change should cause us to delete workspace packages.
|
No, this has been happening for a while. |
Removing this from the gopls/v0.6.2 milestone because it raises issues closely related to #43305 and #42266. If we invalidate workspace packages when the module directive changes, but reinitialization only happens when the This probably means that we should consider the workspacePackages map as part of "metadata" and also mark workspace packages invalid without deleting them, and then only delete them when metadata is fully invalidated on file save. /cc @findleyr |
if vscode reload windows, get the errors:
why GOPROXY set off, that lead downloading module failed.
|
I manual download github.com/stretchr/testify, so can not reproduce. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Change https://go.dev/cl/420956 mentions this issue: |
I am working to eliminate a fork. The fork includes a change to the module import path. As a consequence, when I change git branches, the module import path changes. This causes gopls to be unable to load the workspace, and as a consequence nothing else works. (This includes saving my document without having to use my mouse to click a Cancel button and not having gofmt run). Once gopls is in this state, the only way I have found to recover is to restart VSCode.
Sample error message:
The text was updated successfully, but these errors were encountered: