-
Notifications
You must be signed in to change notification settings - Fork 18k
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
x/tools/gopls: GOFLAGS=-mod=readonly is no longer honoured #44008
Comments
Note the Go version here is significant. This is not reproducible with go1.15 |
Just a note, The bisected commit is actually related since it enabled https://go-review.googlesource.com/c/tools/+/274532 - Should |
Ah, thanks @leitzler - I'd forgotten about The bisected commit is actually https://go-review.googlesource.com/c/tools/+/275442, which confuses me. In any case, I'm very likely behind so would appreciate help understanding why Perhaps one answer is that it gives a more natively Assuming |
CL 275442 fixed a bug that broke the setting. gopls needs to control the -mod flag very explicitly -- we can't allow the user to override it broadly. When we changed to -mod=readonly as the default, I added allowModfileModifications as an opt-out, but we don't test it and it will eventually be removed. If you want the default behavior you should remove the opt-out, not add additional configuration. The 1.15/1.16 difference is an implementation detail; in 1.15 auto is the default, so with allowModfileModifications enabled we pass no -mod flag, which happens to allow the GOFLAGS value through. In 1.16 we have to pass -mod=mod, which blocks GOFLAGS. |
Thanks for clarifying.
Can I please ask that we don't remove this setting until we have a clear answer to the question of how people who want the semantics of Another use case @leitzler points out is the case of manually typed imports (as opposed to via unimported completions). In this case too, the user has intentionally added an import that needs to be satisfied by a module requirement. It's entirely possibly we can deal with specific cases on a case-by-case basis, i.e. we add some mechanism to deal with unimported completions independent of generally "supporting"
Thanks - your explanation makes it clear we should remove this setting for Go 1.16 if what we are looking to test is the behaviour of |
It's just occurred to me that up until I just raised #44035 I've been working on the assumption that |
#44035 has nothing to do with this issue. It would be entirely possible to send the modifications as edit commands, it just hasn't ever been necessary. When we made the switch to manually-managed go.mod files, we explicitly decided that adding a dependency is much more significant than adding an import and should not happen automatically. As far as I know, you and Pontus are the only people who have ever complained about the change to us, and at this point it's been over two months. I don't think we should be supporting an entire extra mode on evidence that thin. If you want to argue otherwise, that's fine, but it would be much more effective to have it in one issue that actually addresses that question than in this issue and #44035, which address implementation details. |
I wasn't intimating it is related, simply pointing out what my understanding was prior to noticing this, and explaining how (from my perspective at least) I've potentially been talking past you/others.
As I mention in that issue, it would certainly make working in Vim (and potentially other buffer-based editors) more reliable and less surprising. Right now the behaviour is no worse that Go 1.15 on the basis the side effects of
Just so that I'm clear, my understanding is that the following conditions need to be satisfied in order for a user to run into this change in behaviour:
I suspect you and the That said, it's highly likely we are in the minority, not least because we're talking from a Vim perspective. Whilst we might be in the minority, what we are trying to solve for is the best experience for
I raised #44035 because I wasn't aware of another issue that's tracking the change to send That change should, I believe, be made regardless of whether (per this discussion) we retain a mode that emulates |
-mod=readonly (manual go.mod control) has been the default for all users since https://github.com/golang/tools/releases/tag/gopls%2Fv0.6.0, and yes, gopls does auto-update for vscode users. The change in behavior was inspired by go 1.16, but is not coupled to it. I'm not sure what you mean by goimports-like handling, but the rule is simple: gopls never modifies a user's go.mod without them explicitly requesting it by accepting a quick fix or code lens. I would therefore expect that many or most gopls users have at some point added an import that they do not have a matching dependency for. Again, the issue you are reporting here is an implementation detail of an opt-out that I intended to be a last resort. If you want to discuss the -mod=readonly change, I strongly suggest you open a new issue laying out your explanation, from first principles, of why you think Vim users would prefer to have their |
Thanks for clarifying. I'll open an issue tomorrow as you suggest. |
I opened #44765 so believe this issue can now be closed. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
First:
Then open
main.go
What did you expect to see?
No changes to
go.mod
What did you see instead?
Bisected down to 9a0e0bb, which looks unrelated.
cc @stamblerre
FYI @leitzler
The text was updated successfully, but these errors were encountered: