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

cmd/go: provide a better error message when no modules exist in workspace #49594

Closed
sylr opened this issue Nov 15, 2021 · 6 comments
Closed

cmd/go: provide a better error message when no modules exist in workspace #49594

sylr opened this issue Nov 15, 2021 · 6 comments

Comments

@sylr
Copy link

sylr commented Nov 15, 2021

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

$ go version
go version devel go1.18-c239790 Sat Nov 13 03:33:55 2021 +0000 darwin/arm64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/sylvain/go/bin"
GOCACHE="/Users/sylvain/Library/Caches/go-build"
GOENV="/Users/sylvain/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/sylvain/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/sylvain/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17.2/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/sylvain/git/go-cache/examples/metered/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/19/d_hlhyz50bs8pbrg6_xn43km0000gp/T/go-build3653344954=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Tried to test go mod workspace and ended up with a panic.

$ cd /tmp
$ git clone https://github.com/sylr/go-cache go-work-panic
$ cd go-work-panic
$ git checkout origin/go-work-panic
$ cd examples/metered
$ gotip build .
panic: in workspace mode, but pruning is not workspace in newRequirements

goroutine 1 [running]:
cmd/go/internal/modload.newRequirements(0x0, {0x0?, 0x0, 0x5?}, 0x0)
	/Users/sylvain/sdk/gotip/src/cmd/go/internal/modload/buildlist.go:118 +0x5d8
cmd/go/internal/modload.LoadModFile({0x100bf2f38, 0x140001a4000})
	/Users/sylvain/sdk/gotip/src/cmd/go/internal/modload/init.go:695 +0x538
cmd/go/internal/modload.LoadPackages({0x100bf2f38?, 0x140001a4000}, {{0x0, 0x0}, 0x14000020060, 0x0, {0x0, 0x0}, 0x0, 0x1, ...}, ...)
	/Users/sylvain/sdk/gotip/src/cmd/go/internal/modload/load.go:341 +0x19c
cmd/go/internal/load.PackagesAndErrors({0x100bf2f38?, 0x140001a4000?}, {0x0?, 0x0?, 0x0?}, {0x1400019e170, 0x1, 0x1})
	/Users/sylvain/sdk/gotip/src/cmd/go/internal/load/pkg.go:2647 +0x120
cmd/go/internal/work.runBuild({0x100bf2f38, 0x140001a4000}, 0x1400002c390?, {0x1400019e170, 0x1, 0x1})
	/Users/sylvain/sdk/gotip/src/cmd/go/internal/work/build.go:398 +0x78
main.invoke(0x100ebe440, {0x1400019e160, 0x2, 0x2})
	/Users/sylvain/sdk/gotip/src/cmd/go/main.go:218 +0x2b0
main.main()
	/Users/sylvain/sdk/gotip/src/cmd/go/main.go:175 +0x770

What did you expect to see?

What did you see instead?

@sten4eg
Copy link

sten4eg commented Nov 15, 2021

this is a duplicate #49591

@seankhliao
Copy link
Member

Duplicate of #49594

@seankhliao seankhliao marked this as a duplicate of #49594 Nov 15, 2021
@matloob
Copy link
Contributor

matloob commented Nov 15, 2021

Hi, I haven't had time to look at it, but I'm wondering how we know this is a duplicate of #49591? Do we know that they're happening for the same reason?

@seankhliao
Copy link
Member

seankhliao commented Nov 15, 2021

I assumed they were dups based on the identical panic message and stacktrace

they also both fail with either of go build or go work sync

@matloob
Copy link
Contributor

matloob commented Nov 19, 2021

I will reopen this to provide a better error message.

@matloob matloob reopened this Nov 19, 2021
@matloob matloob changed the title go work panic cmd/go: provide a better error message when no modules exist in workspace Nov 19, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/365319 mentions this issue: cmd/go: report a helpful error when there are no modules in workspace

@golang golang locked and limited conversation to collaborators Nov 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants