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

Command 'gopls.package_symbols' failed: Error: no package metadata for file {filename} #3681

Open
BrunoKrugel opened this issue Feb 12, 2025 · 4 comments
Assignees
Milestone

Comments

@BrunoKrugel
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    -go1.23.6 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.18.0-pre.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.93.1
  • Check your installed extensions to get the version of the VS Code Go extension
   golang.org/x/tools/[email protected] h1:+airkGmhm12YT67Lcv/SpkQfIe+9LiumzV1SL1+jNZU=
    github.com/BurntSushi/[email protected] h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:1xaZTydL5Gsg78QharTwKfA9FY9CZ1VQj6D/AZEvHR0=
    golang.org/x/[email protected] h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
    golang.org/x/[email protected] h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
    golang.org/x/[email protected] h1:L2k9GUV2TpQKVRGMjN94qfUMgUwOFimSQ6gipyJIjKw=
    golang.org/x/[email protected] h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
    golang.org/x/[email protected] h1:Hd/d+QygQ355a6wowhs7TdfG8iaFPkctgkKN/hhFRWU=
    golang.org/x/[email protected] h1:NPGnvPOTgnjBc9HTaUx+nj+EaUYxl5SJOWqaDYGaFYw=
    honnef.co/go/[email protected] h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=
    mvdan.cc/[email protected] h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

  "gopls": {
    "ui.diagnostic.staticcheck": true,
    "ui.semanticTokens": true,
    "verboseOutput": true,
    "codelenses": {
      "gc_details": true
    }
  },

Describe the bug

After Release v0.45.1, every time I save a non .go file in my project (for example, a .json or Makefile) I receive the error Command 'gopls.package_symbols' failed: Error: no package metadata for file {filename}

Steps to reproduce the behavior:

  1. Save any non .go file (for example a .json) inside a Go project.

Screenshots or recordings

Command 'gopls.package_symbols' failed: Error: no package metadata for file file:///{filepath}/{filename}.json.
@gopherbot gopherbot added this to the Untriaged milestone Feb 12, 2025
@jbdk
Copy link

jbdk commented Feb 13, 2025

I had the same problem.
Solved it by switching "Go for Visual Studio Code" extension from pre-release version to release (v0.44.0).
I don't know if you want to stay on the pre-release version, but I had to get rid of those error messages somehow.

@BrunoKrugel
Copy link
Author

I had the same problem. Solved it by switching "Go for Visual Studio Code" extension from pre-release version to release (v0.44.0). I don't know if you want to stay on the pre-release version, but I had to get rid of those error messages somehow.

Yeah I had to leave the pre-release due this error.

@h9jiang h9jiang modified the milestones: Untriaged, v0.46.0 Feb 13, 2025
@h9jiang h9jiang self-assigned this Feb 13, 2025
@h9jiang
Copy link
Member

h9jiang commented Feb 13, 2025

Thanks for reporting this. The go extension should not trigger any package_symbol command against non-go file.

This is a mistake. Let me fix it and release v0.45.2 to make the pre-release version healthy.

@jakebailey
Copy link

It also needs to filter out non-file schemes, since those are also rejected (I have gotten the error for the git scheme, untitled, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants