Skip to content

cmd/go: show why indirect dependencies are needed #26620

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

Closed
gregory-m opened this issue Jul 26, 2018 · 8 comments
Closed

cmd/go: show why indirect dependencies are needed #26620

gregory-m opened this issue Jul 26, 2018 · 8 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@gregory-m
Copy link
Contributor

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

go version go1.11beta2 darwin/amd64

What did you do?

⇢ $ cat main.go
package main

import "github.com/aws/aws-sdk-go/service/s3"

func main() {
}
⇢ $ go1.11beta2 mod -init && go1.11beta2 mod -sync
go: creating new go.mod: module github.com/gregory-m/mod-test
go: finding github.com/aws/aws-sdk-go/service/s3 latest
go: finding github.com/aws/aws-sdk-go/service latest
go: finding github.com/smartystreets/goconvey/convey latest
go: finding github.com/stretchr/testify/assert latest
go: finding github.com/smartystreets/goconvey latest
go: finding golang.org/x/net/http2 latest
go: finding golang.org/x/net latest
go: finding github.com/davecgh/go-spew/spew latest
go: finding github.com/pmezard/go-difflib/difflib latest
go: finding github.com/smartystreets/assertions latest
go: finding golang.org/x/text/unicode/bidi latest
go: finding golang.org/x/text/unicode/norm latest
go: finding golang.org/x/text/unicode latest
go: finding golang.org/x/text/secure/bidirule latest
go: finding golang.org/x/text/secure latest
go: finding github.com/gopherjs/gopherjs/js latest
go: finding github.com/gopherjs/gopherjs latest
⇢ $ cat go.mod
module github.com/gregory-m/mod-test

require (
	github.com/aws/aws-sdk-go v1.14.33
	github.com/davecgh/go-spew v1.1.0 // indirect
	github.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f // indirect
	github.com/jtolds/gls v4.2.1+incompatible // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/smartystreets/assertions v0.0.0-20180725160413-e900ae048470 // indirect
	github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect
	github.com/stretchr/testify v1.2.2 // indirect
	golang.org/x/net v0.0.0-20180724234803-3673e40ba225 // indirect
	golang.org/x/text v0.3.0 // indirect
)
⇢ $ go1.11beta2 mod -graph
github.com/gregory-m/mod-test github.com/aws/[email protected]
github.com/gregory-m/mod-test github.com/davecgh/[email protected]
github.com/gregory-m/mod-test github.com/go-ini/[email protected]
github.com/gregory-m/mod-test github.com/gopherjs/[email protected]
github.com/gregory-m/mod-test github.com/jmespath/[email protected]
github.com/gregory-m/mod-test github.com/jtolds/[email protected]+incompatible
github.com/gregory-m/mod-test github.com/pmezard/[email protected]
github.com/gregory-m/mod-test github.com/smartystreets/[email protected]
github.com/gregory-m/mod-test github.com/smartystreets/[email protected]
github.com/gregory-m/mod-test github.com/stretchr/[email protected]
github.com/gregory-m/mod-test golang.org/x/[email protected]
github.com/gregory-m/mod-test golang.org/x/[email protected]
github.com/aws/[email protected] github.com/go-ini/[email protected]
github.com/aws/[email protected] github.com/jmespath/[email protected]

What did you expect to see?

Reason why gopherjs or any other indirect dependency added to mod file.

What did you see instead?

No simple way to understand why indirect dependencies added to mod file.

@oiooj oiooj added the modules label Jul 26, 2018
@bcmills
Copy link
Contributor

bcmills commented Jul 26, 2018

The -pgraph flag that @rsc mentioned in #26581 (comment) should address this, I think.

@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 26, 2018
@bcmills bcmills added this to the Go1.11 milestone Jul 26, 2018
@bcmills bcmills changed the title cmd/go mod -graph does not show why indirect dependencies introduced cmd/go: show why indirect dependencies are needed Jul 26, 2018
@flibustenet
Copy link

Since go.mod is versioned it could be fine to record the origin of the indirect dependencies directly in the comments

// indirect from ... (and ... and ...)

@bcmills
Copy link
Contributor

bcmills commented Jul 26, 2018

For builds involving a lot of packages that could get pretty ungainly, and it would potentially add a lot of unnecessary diffs as the set of packages changes over time.

@pwaller
Copy link
Contributor

pwaller commented Aug 2, 2018

Hm. The current behaviour looks quite broken to me, I can't explain the output of this. Is it because the vast majority of the packages don't have their own concrete mod files yet?

It's confusing that it shows all of these as hanoverd imports - in reality hanoverd only imports a couple of packages, including docker, which results in quite a large tree.

But then, gopkg.in/[email protected] gets its own line presumably because it is the only one with a mod file?

Output of `go mod graph`
github.com/sensiblecodeio/hanoverd github.com/Azure/[email protected]
github.com/sensiblecodeio/hanoverd github.com/Microsoft/[email protected]
github.com/sensiblecodeio/hanoverd github.com/Nvveen/[email protected]
github.com/sensiblecodeio/hanoverd github.com/codegangsta/[email protected]
github.com/sensiblecodeio/hanoverd github.com/containerd/[email protected]
github.com/sensiblecodeio/hanoverd github.com/davecgh/[email protected]
github.com/sensiblecodeio/hanoverd github.com/docker/[email protected]
github.com/sensiblecodeio/hanoverd github.com/docker/[email protected]
github.com/sensiblecodeio/hanoverd github.com/docker/[email protected]
github.com/sensiblecodeio/hanoverd github.com/docker/[email protected]
github.com/sensiblecodeio/hanoverd github.com/fsnotify/[email protected]
github.com/sensiblecodeio/hanoverd github.com/gogo/[email protected]
github.com/sensiblecodeio/hanoverd github.com/golang/[email protected]
github.com/sensiblecodeio/hanoverd github.com/golang/[email protected]
github.com/sensiblecodeio/hanoverd github.com/google/[email protected]
github.com/sensiblecodeio/hanoverd github.com/gorilla/[email protected]
github.com/sensiblecodeio/hanoverd github.com/gorilla/[email protected]
github.com/sensiblecodeio/hanoverd github.com/gorilla/[email protected]
github.com/sensiblecodeio/hanoverd github.com/hpcloud/[email protected]
github.com/sensiblecodeio/hanoverd github.com/onsi/[email protected]
github.com/sensiblecodeio/hanoverd github.com/onsi/[email protected]
github.com/sensiblecodeio/hanoverd github.com/opencontainers/[email protected]
github.com/sensiblecodeio/hanoverd github.com/opencontainers/[email protected]
github.com/sensiblecodeio/hanoverd github.com/opencontainers/[email protected]
github.com/sensiblecodeio/hanoverd github.com/pkg/[email protected]
github.com/sensiblecodeio/hanoverd github.com/pmezard/[email protected]
github.com/sensiblecodeio/hanoverd github.com/pwaller/[email protected]
github.com/sensiblecodeio/hanoverd github.com/sensiblecodeio/[email protected]
github.com/sensiblecodeio/hanoverd github.com/sensiblecodeio/[email protected]
github.com/sensiblecodeio/hanoverd github.com/sirupsen/[email protected]
github.com/sensiblecodeio/hanoverd github.com/stretchr/[email protected]
github.com/sensiblecodeio/hanoverd github.com/vaughan0/[email protected]
github.com/sensiblecodeio/hanoverd golang.org/x/[email protected]
github.com/sensiblecodeio/hanoverd golang.org/x/[email protected]
github.com/sensiblecodeio/hanoverd golang.org/x/[email protected]
github.com/sensiblecodeio/hanoverd golang.org/x/[email protected]
github.com/sensiblecodeio/hanoverd golang.org/x/[email protected]
github.com/sensiblecodeio/hanoverd golang.org/x/[email protected]
github.com/sensiblecodeio/hanoverd google.golang.org/[email protected]
github.com/sensiblecodeio/hanoverd google.golang.org/[email protected]
github.com/sensiblecodeio/hanoverd gopkg.in/airbrake/[email protected]
github.com/sensiblecodeio/hanoverd gopkg.in/[email protected]
github.com/sensiblecodeio/hanoverd gopkg.in/gemnasium/[email protected]
github.com/sensiblecodeio/hanoverd gopkg.in/[email protected]
github.com/sensiblecodeio/hanoverd gopkg.in/[email protected]
github.com/sensiblecodeio/hanoverd [email protected]+incompatible
gopkg.in/[email protected] gopkg.in/[email protected]

@bcmills
Copy link
Contributor

bcmills commented Aug 2, 2018

Is it because the vast majority of the packages don't have their own concrete mod files yet?

I think so, yes. Was github.com/sensiblecodeio/hanoverd the main module in that invocation?

@pwaller
Copy link
Contributor

pwaller commented Aug 2, 2018

Yes.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/128359 mentions this issue: cmd/go: add go mod why

@pwaller
Copy link
Contributor

pwaller commented Aug 8, 2018

@rsc: I'm concerned that the above CL might not actually fix the issue presented.

I understand there are two things going on, (1) you are addressing, and (2) not obviously?

  1. That there is the module+package graph, which go mod why is intended to explore.

  2. If I understand the outputs and my experience above correctly, -graph is not reporting edges in the module graph.

It's perhaps not explicitly clear, but in the outputs of -graph presented by the original issue and in my comment, -graph is attributing a huge swathe of dependencies to github.com/gregory-m/mod-test (OP) and github.com/sensiblecodeio/hanoverd (mine), when actually they are indirect dependencies. The only other edges shown appear to be for repositories which have physical .mod files.

I'd expect this is intended to be shown in -graph, but understand it is not currently?

@golang golang locked and limited conversation to collaborators Aug 10, 2019
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants