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

For any files which have linux or windows in their names, got this error: This file is within module ".", which is not included in your workspace. #3120

Closed
qianzhangxa opened this issue Jan 10, 2024 · 4 comments
Labels
FrozenDueToAge gopls gopls related issues WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@qianzhangxa
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.
    • 1.21.5
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • v0.14.2
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.85.1
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.40.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
         Checking configured tools....
         GOBIN: undefined
         toolsGopath: 
         gopath: /Users/qzhang/go
         GOROOT: /Users/qzhang/sdk/go1.21.5
         PATH: /Users/qzhang/sdk/go1.21.5/bin:/usr/local/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/qzhang/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/qzhang/bin:/usr/local/go/bin
         PATH (vscode launched with): /usr/local/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/qzhang/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/qzhang/bin:/usr/local/go/bin
         
           go: /Users/qzhang/sdk/go1.21.5/bin/go: go version go1.21.5 darwin/amd64
         
           gopls:  /Users/qzhang/go/bin/gopls  (version: v0.14.2 built with go: go1.21.5)
           gotests:  not installed
           gomodifytags: not installed
           impl: not installed
           goplay: not installed
           dlv:  /Users/qzhang/go/bin/dlv  (version: v1.21.2 built with go: go1.21.5)
           staticcheck:  /Users/qzhang/go/bin/staticcheck  (version: v0.4.6 built with go: go1.21.5)
         
         go env
         Workspace Folder (kubernetes): /Users/qzhang/Works/projects/go/src/k8s.io/kubernetes
           GO111MODULE=''
           GOARCH='amd64'
           GOBIN=''
           GOCACHE='/Users/qzhang/Library/Caches/go-build'
           GOENV='/Users/qzhang/Library/Application Support/go/env'
           GOEXE=''
           GOEXPERIMENT=''
           GOFLAGS=''
           GOHOSTARCH='amd64'
           GOHOSTOS='darwin'
           GOINSECURE=''
           GOMODCACHE='/Users/qzhang/go/pkg/mod'
           GONOPROXY=''
           GONOSUMDB=''
           GOOS='darwin'
           GOPATH='/Users/qzhang/go'
           GOPRIVATE=''
           GOPROXY='https://proxy.golang.org,direct'
           GOROOT='/Users/qzhang/sdk/go1.21.5'
           GOSUMDB='sum.golang.org'
           GOTMPDIR=''
           GOTOOLCHAIN='auto'
           GOTOOLDIR='/Users/qzhang/sdk/go1.21.5/pkg/tool/darwin_amd64'
           GOVCS=''
           GOVERSION='go1.21.5'
           GCCGO='gccgo'
           GOAMD64='v1'
           AR='ar'
           CC='clang'
           CXX='clang++'
           CGO_ENABLED='1'
           GOMOD='/Users/qzhang/Works/projects/go/src/k8s.io/kubernetes/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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/7d/xksqy41d6fld6c9x9y2z8kmw0000gn/T/go-build2905093160=/tmp/go-build -gno-record-gcc-switches -fno-common'
         ```
    

Share the Go related settings you have added/edited

    "go.toolsManagement.autoUpdate": true,
    "[go]": {
        "editor.insertSpaces": false,
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        }
    },
    "go.toolsEnvVars": {},
    "gopls": {}

Describe the bug

I am using VS code with Go extension to check Kubernetes source code in my macOS, and I found for any files which have linux or windows in their names (e.g. cgroup_manager_linux.go), I always get this error:

[{
	"resource": "/Users/qzhang/Works/projects/go/src/k8s.io/kubernetes/pkg/kubelet/cm/cgroup_manager_linux.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 4,
	"message": "This file is within module \".\", which is not included in your workspace.\nTo fix this problem, you can add a go.work file that uses this directory.\nSee the documentation for more information on setting up your workspace:\nhttps://github.com/golang/tools/blob/master/gopls/doc/workspace.md.",
	"source": "go list",
	"startLineNumber": 17,
	"startColumn": 9,
	"endLineNumber": 17,
	"endColumn": 11
}]

Steps to reproduce the behavior:

  1. Go to any files which have linux or windows in their names.
  2. See the error below.

image

@gopherbot gopherbot added this to the Untriaged milestone Jan 10, 2024
@hyangah
Copy link
Contributor

hyangah commented Jan 10, 2024

It is golang/go#29202 (os/arch in filenames serve like build tags).

Good news - the upcoming version of the language server is going to improve the build tag handling. gopls v0.15.0-pre.1 is currently out for testing. Can you give it a try and provide feedback/bug reports? (cc @findleyr)

go install golang.org/x/tools/[email protected]

And run "Go: Restart Language Server" command.

@hyangah hyangah added gopls gopls related issues WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 10, 2024
@qianzhangxa
Copy link
Author

qianzhangxa commented Jan 13, 2024

@hyangah Yes, gopls v0.15.0-pre.1 has fixed this issue, thanks!

BTW, do you happen to know when gopls v0.15.0 will be released?

@findleyr
Copy link
Member

@qianzhangxa we're taking out time as this is a large change and we want to have another prerelease, but probably within the next few weeks. Thank you for testing.

@findleyr
Copy link
Member

Closing as this will be fixed by [email protected].

@golang golang locked and limited conversation to collaborators Jan 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls gopls related issues WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants