Skip to content

No packages found for open file #2715

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

Closed
100158318 opened this issue Mar 31, 2023 · 18 comments
Closed

No packages found for open file #2715

100158318 opened this issue Mar 31, 2023 · 18 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@100158318
Copy link

100158318 commented Mar 31, 2023

1、question prompt:
No packages found for open file E:\data\huisi180\project\hszl\api\model\entity\crm\CustomerStatus.go: .
If this file contains build tags, try adding "-tags=" to your gopls "buildFlags" configuration (see (https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags-string).
Otherwise, see the troubleshooting guidelines for help investigating (https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md).

2、
go version go1.20.2 windows/amd64
VS Code 1.77.0
golang.org/x/tools/gopls v0.11.0

3、Problem Description
Create a new file named CustomerStatus.go, change the file name to customerStatus.go, the above error occurs

@gopherbot gopherbot added this to the Untriaged milestone Mar 31, 2023
@findleyr
Copy link
Member

findleyr commented Apr 4, 2023

This looks related to https://go.dev/issue/57081

Can you try installing gopls at master? It may not get confused about the changed case.
https://github.com/golang/tools/blob/master/gopls/doc/advanced.md#unstable-versions

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 4, 2023
@gopherbot
Copy link
Collaborator

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@zfbx
Copy link

zfbx commented Mar 25, 2024

I just had this exact scenario happen to me, created a file, edited the case and now I get this warning and restarting my IDE doesn't make it go away. So this seems to still be an active issue I guess?
go 1.22.0
gopls v0.15.2

@lazybark
Copy link

lazybark commented Mar 27, 2024

I just had this exact scenario happen to me, created a file, edited the case and now I get this warning and restarting my IDE doesn't make it go away. So this seems to still be an active issue I guess? go 1.22.0 gopls v0.15.2

In my case simple go mod tidy solved the problem (had same issue).

go 1.22.1
gopls v0.15.2

@ghost
Copy link

ghost commented Jun 8, 2024

Hey,
I know it's an old thread, but for late googlers, let me share my findings.

I got the same issue “No package found for open file ...” when I copied my project_dir/cmd/module to module2 in VScode for creating a template for a similar module.
For some reasons, VScode renamed my module-filename.go file to module-filename WITHOUT .go extension…
But since VScode with Go linting was smart enough to accept the Go code content as a go file, this happened.

After renaming module-filename to module-filename.go, everything is fine.

@jgalliers
Copy link

For others who come along, this error was related to the use of build flags. After some time and an IDE reload, I got a more verbose message -

No packages found for open file <redacted>/queries_test.go. This file may be excluded due to its build tags; try adding "-tags=<build tag>" to your gopls "buildFlags" configuration See the documentation for more information on working with build tags: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags.

I was in fact using build flags and this is exactly the reason. The file is omitted based on these flags by default.

@nxiaohei
Copy link

After changing the file name from DaemonSet.go to daemonSet.go, the issue still persisted. I deleted the go.mod and go.sum files, reinitialized with go mod init, then ran go clean -modcache and go mod tidy, and it worked normally.

@morningscifi
Copy link

I deleted the go.mod and go.sum files, reinitialized with go mod init, then ran go clean -modcache and go mod tidy, and it worked normally.

Thanks for the suggestion, this cleared up the same issue for me.

I can reproduce the issue by creating a new .go file containing a capital letter, pasting package main with a helloWorld function, then I change the filename to be all lowercase.

Error message (TestCamelCase.go has been renamed testcamelcase.go):

No packages found for open file C:\...\TestCamelCase.go   go list

gopls (server) output

[Error - 11:31:59 PM] Request textDocument/inlayHint failed.
  Message: getting file for InlayHint: no package metadata for file file:///C:/.../TestCamelCase.go

Windows 10
go1.22.7
gopls v0.16.2

@potatochick2020
Copy link

Issue Summary:

I encountered this issue on a Unix-based OS (specifically macOS), and it only occurred with one file in the project rather than the whole project. Based on my observations, this issue seems related to case-sensitive file systems, which are typical on Unix-based operating systems.

Solution:

  1. Rename the problematic file from XXOO.go to XXOO1.go.
  2. Restart VSCode.
  3. Rename the file back from XXOO1.go to XXOO.go.
  4. Restart VSCode again.

This resolved the issue for me.

@a1270107629
Copy link

I have tried all the methods you mentioned, but none of them worked. I upgraded the version of go from 1.22 to 1.23, and the problem was solved on vscode

@AndreiTheDev
Copy link

AndreiTheDev commented Oct 21, 2024

Issue Summary:

I encountered this issue on a Unix-based OS (specifically macOS), and it only occurred with one file in the project rather than the whole project. Based on my observations, this issue seems related to case-sensitive file systems, which are typical on Unix-based operating systems.

Solution:

  1. Rename the problematic file from XXOO.go to XXOO1.go.
  2. Restart VSCode.
  3. Rename the file back from XXOO1.go to XXOO.go.
  4. Restart VSCode again.

This resolved the issue for me.

I have encountered same issue and also on macOS. Same solution to me, it also stated (not every time, this was the very confusing part, sometimes it showed the message sometimes it didn't: "Found case-sensitive problem Repository.go and repository.go" since I renamed the file after creation).

But the solution stated here worked to me also.

@rikusen0335
Copy link

For someone still struggling about this, mine was just forgetting .go suffix lmao

@nekkkkitch
Copy link

So if none of comments helped - in my case module in my go.mod file was named "mod" instead of my project name. Try renaming it like this: module mod -> module MyProject

@weaming
Copy link

weaming commented Dec 12, 2024

update go from 1.22 to go1.23.4 resolved my problem

@Amnesiac9
Copy link

Amnesiac9 commented Feb 4, 2025

In my case, I actually had a function that was named very similar to the file. The package name was completely unrelated. Weird error.

My file name was something like myFunc.go and my function was MyFunc(). I renamed the function and the error went away. Go 1.21

@thomastthai
Copy link

Similar error when using Mage.

@mattjohnsonpint
Copy link

mattjohnsonpint commented May 12, 2025

Just ran into this because I accidently used myfile.Go instead of myfile.go. Renamed it to myfile.go and got stuck with "no packages found for open file".

The rename/quit/rename/quit trick cleared it. Before that, I tried rename and rename back without quitting in between, which was insufficient.

The issue should be re-opened, imho.

@aranw
Copy link

aranw commented May 14, 2025

I'm getting this issue with a package that is in my go modules.

No packages found for open file /go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20250514032051-0d9068ecd233/src/fdb/database.go.
This file is ignored by your gopls build. (go list)

What I don't understand is what does it mean about my gopls build?

My build of gopls is installed using go install as described in the gopls project README

Edit: just thought I should add I have no custom gopls config setting tags or anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests