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: unclear error when path listed in go.work does not exist #55952

Closed
adonovan opened this issue Sep 29, 2022 · 2 comments
Closed

cmd/go: unclear error when path listed in go.work does not exist #55952

adonovan opened this issue Sep 29, 2022 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@adonovan
Copy link
Member

@findleyr and I were briefly confused today by an error message from the Go command:

$ go build ./x
go: open /tmp/foo/y/go.mod: no such file or directory

Where did the name y come from? The answer turned out to be the go.work file, but it wasn't obvious. Here's the context:

$ pwd
/tmp/foo
$ cat go.work 
use ./m
$ cat m/go.mod
module m
$ cat m/m.go
package m
$ go build ./m
$ mv m m2
$ go build ./m2
go: open /tmp/foo/m/go.mod: no such file or directory

Ideally the go command would emit an error more like this:

go: cannot load module m named in go.work file: open /tmp/foo/m/go.mod: no such file or directory
@findleyr
Copy link
Contributor

CC @bcmills @matloob

@bcmills bcmills added the GoCommand cmd/go label Sep 29, 2022
@bcmills bcmills changed the title cmd/go: unclear error from go.work cmd/go: unclear error when path listed in go.work does not exist Sep 29, 2022
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 29, 2022
@bcmills bcmills added this to the Backlog milestone Sep 29, 2022
@gopherbot
Copy link

Change https://go.dev/cl/438147 mentions this issue: cmd/go/internal/modload: improve error message for failing to read module listed in go.work

romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Nov 3, 2022
…dule listed in go.work

Run "go build ./x" in this workspace:

  -- go.work --
  use ./y
  -- x/go.mod --
  module x

  go 1.19
  -- x/m.go --
  package m

It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
It's unclear where the name "y" comes from.
This change will emit error like: "go: cannot load module listed in
go.work file: open /tmp/foo/y/go.mod: no such file or directory"

Fixes golang#55952.

Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
GitHub-Last-Rev: 410de1b
GitHub-Pull-Request: golang#56050
Reviewed-on: https://go-review.googlesource.com/c/go/+/438147
Run-TryBot: hopehook <hopehook@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
@golang golang locked and limited conversation to collaborators Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
4 participants