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: Error loading workspace: You are outside of a module and outside of $GOPATH/src. #51632

Closed
bsap-git opened this issue Mar 12, 2022 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@bsap-git
Copy link

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

go version go1.16.14 linux/amd64

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

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/bsap/.cache/go-build"
GOENV="/home/bsap/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/bsap/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/bsap/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.14"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/bsap/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2001400524=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I closed VSCode after writing two modules within a bigger project. I used replace x => ./packages/x in each go.mod without any problems until reopening. This is similar to #46625

What did you expect to see?

No errors, same state as when I closed it.

What did you see instead?

Error loading workspace: You are outside of a module and outside of $GOPATH/src. If you are using modules, please open your editor to a directory in your module. If you believe this warning is incorrect, please file an issue: https://github.com/golang/go/issues/new.

@seankhliao
Copy link
Member

Same, question as before: what is your directory layout (including module roots) and where did you open vscode?

@seankhliao seankhliao changed the title Error loading workspace: You are outside of a module and outside of $GOPATH/src. s/tools/gopls: Error loading workspace: You are outside of a module and outside of $GOPATH/src. Mar 12, 2022
@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 12, 2022
@seankhliao seankhliao changed the title s/tools/gopls: Error loading workspace: You are outside of a module and outside of $GOPATH/src. x/tools/gopls: Error loading workspace: You are outside of a module and outside of $GOPATH/src. Mar 12, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 12, 2022
@gopherbot gopherbot added this to the Unreleased milestone Mar 12, 2022
@bsap-git
Copy link
Author

analysis_options.yaml  android  bug_report_for_go.iml  go  ios  lib  pubspec.lock  pubspec.yaml  README.md  test  web windows

projects/github_bug_report/bug_report_for_go/go/:
go.mod  main.go  packages

projects/github_bug_report/bug_report_for_go/go/packages:
x

projects/github_bug_report/bug_report_for_go/go/packages/x:
go.mod  x.go

I should've included it to begin with. Here's the top level directory I'm opening and the Go subfolder. However when trying to recreate the hierarchy it's now pointing me to https://github.com/golang/tools/blob/master/gopls/doc/workspace.md; I do not know why it worked before but setting experimentalWorkspaceModule to true has got it working again.

@seankhliao
Copy link
Member

The workspace documentation is the correct place to look when using multiple modules.
I assume it worked before when you only had 1, then wrote a second one while it was still open.

@golang golang locked and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants