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

cmd/gopls: avoid Command 'gopls.generate' failed: Error: All files must be saved first #66957

Open
andig opened this issue Apr 22, 2024 · 2 comments
Labels
gopls Issues related to the Go language server, gopls. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@andig
Copy link
Contributor

andig commented Apr 22, 2024

What version of Go are you using (go version)?

$ go version
go version go1.22.2 darwin/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/andig/Library/Caches/go-build'
GOENV='/Users/andig/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/andig/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/andig/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/andig/htdocs/evcc/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build1839283339=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOROOT/bin/go version: go version go1.22.2 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.22.2
uname -v: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103
ProductName:		macOS
ProductVersion:		14.4.1
BuildVersion:		23E224
lldb --version: lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

What did you do?

Use VScode, switch between branches. Some files remain open that may not exist on the new branch. VScode shows these as missing (red icon).

What did you expect to see?

go generate runs. gopls should be able to differentiate between unsaved and missing files.

What did you see instead?

Running gopls.generate creates an error since it thinkgs the workspace is dirty- which it isn't in this case.

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Apr 22, 2024
@findleyr
Copy link
Contributor

go generate runs. gopls should be able to differentiate between unsaved and missing files.

What about //go:generate directives in open buffers that don't exist on disk? Why is it assumed that the call to go generate would not interact with open files once they are written to disk?

It seems cleaner to keep it simple, and not try to guess about what is and isn't relevant to //go:generate. So I think we should either leave it as is -- all files must be saved -- or remove the check for saved state altogether. I think the current behavior is safest and least surprising.

@findleyr findleyr added this to the gopls/unplanned milestone Apr 26, 2024
@findleyr findleyr added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Apr 26, 2024
@andig
Copy link
Contributor Author

andig commented Apr 26, 2024

Probably true. But it is annoying.

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. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants