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: When go list -m -json -versions returns no versions, it does not include an Origin #66077

Open
mondy opened this issue Mar 3, 2024 · 6 comments
Labels
GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mondy
Copy link

mondy commented Mar 3, 2024

Go version

go version go1.22.0 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\myname\AppData\Local\go-build
set GOENV=C:\Users\myname\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\myname\go\pkg\mod
set GONOPROXY=github.com/myname/*
set GONOSUMDB=github.com/myname/*
set GOOS=windows
set GOPATH=C:\Users\myname\go
set GOPRIVATE=github.com/myname/*
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\myname\scoop\apps\go\current
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\myname\scoop\apps\go\current\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\myname\AppData\Local\Temp\go-build3669545043=/tmp/go-build -gno-record-gcc-switches

What did you do?

Execute go list -m -json -versions fyne.io/fyne/v2/cmd/fyne on go version 1.22.0 and 1.21.7.

What did you see happen?

Execute go list -m -json -versions fyne.io/fyne/v2/cmd/fyne.
Output:

{
        "Path": "fyne.io/fyne/v2/cmd/fyne"
}

Origin field is not output.

Execute with go version 1.21.7.

{
        "Path": "fyne.io/fyne/v2/cmd/fyne",
        "Origin": {
                "VCS": "git",
                "URL": "https://github.com/fyne-io/fyne",
                "Subdir": "cmd/fyne",
                "TagPrefix": "cmd/fyne/",
                "TagSum": "t1:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="
        }
}

Origin field is output.

What did you expect to see?

I would like to get the output of the Origin field in go version 1.22.0 as well.

@seankhliao
Copy link
Member

the issue title says subdirectory, but the report doesn't mention anything about directories?

@mondy
Copy link
Author

mondy commented Mar 3, 2024

the issue title says subdirectory, but the report doesn't mention anything about directories?

fyne.io/fyne/v2/cmd/fyne is subdirectory.

@seankhliao
Copy link
Member

cc @bcmills

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Mar 3, 2024
@bcmills
Copy link
Contributor

bcmills commented Mar 4, 2024

go list -m operates on modules, not packages. fyne.io/fyne/v2/cmd/fyne is a package with the module fyne.io/fyne/v2, not a module in its own right.

Normally, asking about a path that does not refer to a valid module results in an error, but in this case the error is suppressed by the -versions flag. go list -m -json -versions fyne.io/fyne/v2/cmd/fyne is successfully informing you that there are no known versions of that module in existence. It doesn't tell you an Origin for a lack of such versions, because it doesn't know how to compute origins for things that don't exist.

@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
@bcmills bcmills changed the title cmd/go: When go list -m -json -versions is run in a subdirectory, the Origin field is not output. cmd/go: When go list -m -json -versions returns no versions, it does not include an Origin Mar 4, 2024
@bcmills
Copy link
Contributor

bcmills commented Mar 4, 2024

Hmm, there might be an issue here, but it's subtle.

To give a bit more detail, https://go.dev/cl/543216 and https://go.dev/cl/543155 fixed some bugs in which cmd/go was reporting incorrect Origin metadata for mixed-origin data:

In this case, the mixed origin consists of:

  1. The information that https://github.com/fyne-io/fyne does not contain a cmd/fyne at its latest commit, and does not contain any tags that would correspond to a module in that subdirectory, as well as
  2. the information that both https://fyne.io/fyne/v2/cmd/fyne?go-get=1 and https://fyne.io/fyne/v2/cmd?go-get=1 return results without go-import metadata.

In theory, the Origin structure does have enough metadata to represent both of those facts, as shown by the Origin metadata returned for a query for @latest (instead of -versions):

$ GOPROXY=direct gotip list -m -e -json fyne.io/fyne/v2/cmd/fyne@latest
{
        "Path": "fyne.io/fyne/v2/cmd/fyne",
        "Version": "latest",
        "Error": {
                "Err": "module fyne.io/fyne/v2/cmd/fyne: no matching versions for query \"latest\""
        },
        "Origin": {
                "VCS": "git",
                "URL": "https://github.com/fyne-io/fyne",
                "Subdir": "cmd/fyne",
                "Hash": "e332a5e47813bff1af9631cbbfe84654c0143189",
                "TagPrefix": "cmd/fyne/",
                "TagSum": "t1:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
                "Ref": "HEAD"
        }
}

(CC @matloob @samthanawalla @suzmue)

@bcmills bcmills reopened this Mar 4, 2024
@bcmills bcmills added the modules label Mar 4, 2024
@mondy
Copy link
Author

mondy commented Mar 4, 2024

The reason I need this feature is related to #65350.
The feature I really want is to get an installable version with go install.

Find the root directory by trimming Origin.Subdir from the Path of the retrieved JSON data. And Versions can be reliably obtained from the root directory. I need the Origin information for this.

If Origin was intentionally erased (if it was decided as a specification), it may not be necessary.

@bcmills bcmills added this to the Backlog milestone Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants