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: "unexpected files in command-line-arguments package" bug (via telemetry) #64557

Open
adonovan opened this issue Dec 5, 2023 · 11 comments
Assignees
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Dec 5, 2023

This stacks EVz2Fg, ELG5Yw, ND0D7A were reported by telemetry:

// buildMetadata populates the updates map with metadata updates to
// apply, based on the given pkg. It recurs through pkg.Imports to ensure that
// metadata exists for all dependencies.
func buildMetadata(updates map[PackageID]*metadata.Package, pkg *packages.Package, loadDir string, standalone bool) {
	// Allow for multiple ad-hoc packages in the workspace (see #47584).
	pkgPath := PackagePath(pkg.PkgPath)
	id := PackageID(pkg.ID)

	if metadata.IsCommandLineArguments(id) {
		if len(pkg.CompiledGoFiles) != 1 {
			bug.Reportf("unexpected files in command-line-arguments package: %v", pkg.CompiledGoFiles)
			return
gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.NarrowestMetadataForFile:1
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseChangedFiles:28
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshot:25
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshots.func1:2
runtime.goexit:0
golang.org/x/tools/gopls@v0.14.2 go1.21.0 darwin/arm64 (6)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Duplicates:

This stack dDf6yw was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.selectPackageForFile:1
golang.org/x/tools/gopls/internal/lsp/source.NarrowestPackageForFile:1
golang.org/x/tools/gopls/internal/lsp/source.SignatureHelp:6
golang.org/x/tools/gopls/internal/lsp.(*Server).signatureHelp:9
golang.org/x/tools/gopls/internal/lsp.(*Server).SignatureHelp:1
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch:490
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3:5
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4:52
golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1:2
golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2:3
runtime.goexit:0
golang.org/x/tools/gopls@v0.14.2 go1.21.6 windows/amd64 vscode (1)

This stack Es6nFQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:143
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.NarrowestMetadataForFile:1
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseChangedFiles:28
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshot:25
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnoseSnapshots.func1:2
runtime.goexit:0
golang.org/x/tools/gopls@v0.14.2 go1.21.3 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

This stack OBhdqw was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:143
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/source.NarrowestMetadataForFile:1
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).ListImports.func1:25
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).run.func1:2
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).run:72
golang.org/x/tools/gopls/internal/lsp.(*commandHandler).ListImports:2
golang.org/x/tools/gopls/internal/lsp/command.Dispatch:73
golang.org/x/tools/gopls/internal/lsp.(*Server).executeCommand:19
golang.org/x/tools/gopls/internal/lsp.(*Server).ExecuteCommand:1
golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch:606
golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3:5
golang.org/x/tools/gopls@v0.14.2 go1.21.3 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Dups: gRw1-A ibW47g Dfhd-g _p1kkQ RcEuHA fJJ7HA e0uUFg 9M1npA WNZ--Q

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 5, 2023
@gopherbot gopherbot added this to the Unreleased milestone Dec 5, 2023
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.15.0 Dec 7, 2023
@adonovan
Copy link
Member Author

adonovan commented Feb 2, 2024

Apparently one can create a command-line-arguments package with zero CompiledGoFiles:

xtools$ echo "" > b.go
xtools$ go list -e  -compiled -json  ./b.go
{
	"Dir": "/Users/adonovan/w/xtools",
	"ImportPath": "command-line-arguments",
	"Match": [
		"./b.go"
	],
	"Incomplete": true,
	"Stale": true,
	"StaleReason": "build ID mismatch",
	"GoFiles": [
		"b.go"
	],
	"InvalidGoFiles": [
		"b.go"
	],
	"Error": {
		"ImportStack": [
			"command-line-arguments"
		],
		"Pos": "b.go:1:2",
		"Err": "expected 'package', found 'EOF'"
	}
}

@adonovan adonovan self-assigned this Feb 2, 2024
@gopherbot
Copy link

Change https://go.dev/cl/560465 mentions this issue: gopls/internal/cache: allow command-line-package >1 CompileGoFiles

@adonovan
Copy link
Member Author

This stack ibW47g was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Reportf:1
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:7
golang.org/x/tools/gopls/internal/lsp/cache.buildMetadata:143
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).load:173
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).resolveImportGraph:11
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getImportGraph.func1:2
runtime.goexit:0
golang.org/x/tools/gopls@v0.14.2 devel windows/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Feb 27, 2024

This stack gRw1-A was reported by telemetry:

buildMetadata:14 is:

bug.Reportf("unexpected files in command-line-arguments package: %v", pkg.CompiledGoFiles)
gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:35
golang.org/x/tools/gopls/internal/util/bug.Reportf:1
golang.org/x/tools/gopls/internal/cache.buildMetadata:14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:36
golang.org/x/tools/gopls/internal/cache.(*Snapshot).resolveImportGraph:11
golang.org/x/tools/gopls/internal/cache.(*Snapshot).getImportGraph.func1:2
runtime.goexit:0
golang.org/x/tools/gopls@v0.15.0-pre.2 go1.22rc1 linux/amd64 vscodium (2)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Mar 5, 2024

Reopening due to new field reports at v0.15.

@adonovan adonovan reopened this Mar 5, 2024
@adonovan
Copy link
Member Author

This stack _p1kkQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.buildMetadata:+156
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/server.(*commandHandler).ListImports.func1:+25
golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3
golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+68
golang.org/x/tools/gopls/internal/server.(*commandHandler).ListImports:+2
golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+79
golang.org/x/tools/gopls/internal/server.(*server).ExecuteCommand:+19
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+674
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls@v0.15.1 go1.22.0 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack RcEuHA was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.buildMetadata:+156
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.selectPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.CodeActions:+65
golang.org/x/tools/gopls/internal/server.(*server).CodeAction:+95
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+160
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack fJJ7HA was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedFiles:+33
golang.org/x/tools/gopls/internal/server.(*server).diagnoseSnapshot:+27
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedViews.func1:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.2 go1.21.8 darwin/arm64 other,vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

This stack e0uUFg was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/cache.(*Snapshot).orphanedFileDiagnostics:+13
golang.org/x/tools/gopls/internal/cache.(*Session).OrphanedFileDiagnostics:+50
golang.org/x/tools/gopls/internal/server.(*server).diagnoseChangedViews:+54
golang.org/x/tools/gopls/internal/server.(*server).didModifyFiles.func2:+1
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Apr 2, 2024

This stack 9M1npA was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.NarrowestMetadataForFile:+1
golang.org/x/tools/gopls/internal/server.goLinks:+16
golang.org/x/tools/gopls/internal/server.(*server).DocumentLink:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+291
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@adonovan
Copy link
Member Author

adonovan commented Apr 2, 2024

This stack WNZ--Q was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Reportf:+1
golang.org/x/tools/gopls/internal/cache.buildMetadata:+14
golang.org/x/tools/gopls/internal/cache.(*Snapshot).load:+208
golang.org/x/tools/gopls/internal/cache.(*Snapshot).MetadataForFile:+36
golang.org/x/tools/gopls/internal/golang.selectPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.NarrowestPackageForFile:+1
golang.org/x/tools/gopls/internal/golang.Highlight:+6
golang.org/x/tools/gopls/internal/server.(*server).DocumentHighlight:+14
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+280
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.15.2 go1.22.1 linux/amd64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants