Skip to content
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: remove the "allowModfileModifications" setting #65546

Closed
findleyr opened this issue Feb 6, 2024 · 8 comments
Closed

x/tools/gopls: remove the "allowModfileModifications" setting #65546

findleyr opened this issue Feb 6, 2024 · 8 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Feb 6, 2024

Following up on #56570, we should remove the deprecated allowModFileModifications setting.

Quoting: #56570 (comment):

Generally speaking, this setting means "whatever the go command does to your go.mod file is OK". That's not a coherent mode of operation for gopls to support, which is why it has no test coverage. Additionally, the documentation says "this option will eventually be removed".

We should surface the deprecation notice in gopls@v0.15.0, and remove in gopls@v0.16.0.

I don't think this setting works well, so I don't see how it could be useful to any users. However, if you need this setting, please explain why!

@findleyr findleyr added this to the gopls/v0.16.0 milestone Feb 6, 2024
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 6, 2024
@tuxerrante
Copy link

After adding the related setting in the gopls section I still have the same error.

settings.json

 {
   ...
   "gopls": {
        "build.allowModfileModifications": false
    }
}

A VSCode restart didn't solve.

@metal3d
Copy link

metal3d commented Apr 4, 2024

Using CoC on neovim, if I don't use this setting, I need to close, then go mod tidy, then reopen the project to make gopls accept newly installed package imports.

So, maybe it's necessary, or, if not, having a workaround for this.

@findleyr
Copy link
Contributor Author

@metal3d

A couple comments:

  • You can add "languageserver": { "go": { "filetypes": ["go", "gomod"] } } to your coc-settings.json to enable gopls for go.mod files. Then it should (1) sync go.mod file changes to gopls automatically, and (2) suggest a code lens to run go mod tidy.
  • You don't need to restart to reopen the project to restart gopls: just run :CocRestart.

In general, the behavior of letting the go command mutate the mod file is not well supported. It is bad behavior for a language server to modify file content without an explicit user action.

@findleyr
Copy link
Contributor Author

@tuxerrante sorry I don't understand what you're saying. I think you want the nagging warning to go away? In that case, please remove this setting from your settings.json file.

@tuxerrante
Copy link

@tuxerrante sorry I don't understand what you're saying. I think you want the nagging warning to go away? In that case, please remove this setting from your settings.json file.

I had the issue already before adding that setting.
I was trying different possibilities in order to make the warning go away.
That's what I meant.

@findleyr
Copy link
Contributor Author

findleyr commented Apr 16, 2024

@tuxerrante, with empty settings.json you should not get any warnings about this setting. Perhaps it is set in workspace settings?

@gopherbot
Copy link

Change https://go.dev/cl/579435 mentions this issue: gopls/internal/settings: remove support for "allowModfileModifications"

@tuxerrante
Copy link

@tuxerrante, with empty settings.json you should not get any warnings about this setting. Perhaps it is set in workspace settings?

It was hidden in the user settings under AppData, not sure which plugin could have created it.
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants