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: go.mod should codify dependencies in multi-module mode before tagging new module #32344

Closed
jadekler opened this issue May 30, 2019 · 6 comments
Labels

Comments

@jadekler
Copy link
Contributor

@jadekler jadekler commented May 30, 2019

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

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/deklerk/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/deklerk/workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/tmp/google-cloud-go/logging/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/qq/y4kgdzjn45v0vzhfp_1j79k800h16k/T/go-build294552016=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

cd /my-project
# already has a go.mod
cd subdir
go mod init
go mod tidy

(the subdir is https://github.com/googleapis/google-cloud-go/tree/master/logging)

What did you expect to see?

A go.mod with all the subdir dependencies codified.

What did you see instead?

module my-project/subdir

go 1.12

(actually, using real example, the module name is cloud.google.com/go/logging)

Why does go mod tidy not codify all the newly-carved-out module's dependencies? Similarly, go mod graph returns nothing:

deklerk at deklerk-macbookpro in /tmp/google-cloud-go/logging on master*
$ go mod graph
deklerk at deklerk-macbookpro in /tmp/google-cloud-go/logging on master*

I assume that once I publish a logging/v0.0.1, go mod tidy will magically begin working as expected...?

@thepudds

This comment has been minimized.

Copy link

@thepudds thepudds commented May 31, 2019

Hi @jadekler Maybe this is an incarnation of #27063?

Does go build error out, or complete successfully?

@thepudds thepudds added the modules label May 31, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented May 31, 2019

What do you mean by “codify”?

This is most definitely another instance of #27063:

~/src/cloud.google.com/go/logging$ gotip mod init
go: creating new go.mod: module cloud.google.com/go/logging

~/src/cloud.google.com/go/logging$ gotip mod tidy
go: finding google.golang.org/grpc v1.21.0
go: finding google.golang.org/genproto latest
go: downloading github.com/googleapis/gax-go v2.0.2+incompatible
go: downloading github.com/googleapis/gax-go/v2 v2.0.4
go: downloading google.golang.org/genproto v0.0.0-20190530194941-fb225487d101
go: downloading google.golang.org/grpc v1.21.0
go: extracting github.com/googleapis/gax-go/v2 v2.0.4
go: extracting github.com/googleapis/gax-go v2.0.2+incompatible
go: extracting google.golang.org/grpc v1.21.0
go: extracting google.golang.org/genproto v0.0.0-20190530194941-fb225487d101
go: finding cloud.google.com/go v0.39.0
go: downloading cloud.google.com/go v0.39.0
go: extracting cloud.google.com/go v0.39.0
go: downloading github.com/google/go-cmp v0.3.0
go: extracting github.com/google/go-cmp v0.3.0
go: finding go.opencensus.io v0.22.0
go: downloading go.opencensus.io v0.22.0
go: extracting go.opencensus.io v0.22.0
go: finding golang.org/x/oauth2 latest
go: finding google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8
go: finding golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd
go: finding google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb
go: finding golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09

~/src/cloud.google.com/go/logging$ gotip list -m all
cloud.google.com/go/logging

~/src/cloud.google.com/go/logging$ gotip list all
go: finding golang.org/x/oauth2 latest
go: finding google.golang.org/genproto latest
can't load package: package cloud.google.com/go/logging: unknown import path "cloud.google.com/go/logging": ambiguous import: found cloud.google.com/go/logging in multiple modules:
        cloud.google.com/go/logging (/usr/local/google/home/bcmills/src/cloud.google.com/go/logging)
        cloud.google.com/go v0.39.0 (/usr/local/google/home/bcmills/pkg/mod/cloud.google.com/go@v0.39.0/logging)
can't load package: package cloud.google.com/go/logging/apiv2: unknown import path "cloud.google.com/go/logging/apiv2": ambiguous import: found cloud.google.com/go/logging/apiv2 in multiple modules:
        cloud.google.com/go/logging (/usr/local/google/home/bcmills/src/cloud.google.com/go/logging/apiv2)
        cloud.google.com/go v0.39.0 (/usr/local/google/home/bcmills/pkg/mod/cloud.google.com/go@v0.39.0/logging/apiv2)
can't load package: package cloud.google.com/go/logging/internal: unknown import path "cloud.google.com/go/logging/internal": ambiguous import: found cloud.google.com/go/logging/internal in multiple modules:
        cloud.google.com/go/logging (/usr/local/google/home/bcmills/src/cloud.google.com/go/logging/internal)
        cloud.google.com/go v0.39.0 (/usr/local/google/home/bcmills/pkg/mod/cloud.google.com/go@v0.39.0/logging/internal)
can't load package: package cloud.google.com/go/logging/internal/testing: unknown import path "cloud.google.com/go/logging/internal/testing": ambiguous import: found cloud.google.com/go/logging/internal/testing in multiple modules:
        cloud.google.com/go/logging (/usr/local/google/home/bcmills/src/cloud.google.com/go/logging/internal/testing)
        cloud.google.com/go v0.39.0 (/usr/local/google/home/bcmills/pkg/mod/cloud.google.com/go@v0.39.0/logging/internal/testing)
can't load package: package cloud.google.com/go/logging/logadmin: unknown import path "cloud.google.com/go/logging/logadmin": ambiguous import: found cloud.google.com/go/logging/logadmin in multiple modules:
        cloud.google.com/go/logging (/usr/local/google/home/bcmills/src/cloud.google.com/go/logging/logadmin)
        cloud.google.com/go v0.39.0 (/usr/local/google/home/bcmills/pkg/mod/cloud.google.com/go@v0.39.0/logging/logadmin)
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented May 31, 2019

Duplicate of #27063

@bcmills bcmills marked this as a duplicate of #27063 May 31, 2019
@bcmills bcmills closed this May 31, 2019
@jadekler

This comment has been minimized.

Copy link
Contributor Author

@jadekler jadekler commented Jun 3, 2019

What do you mean by “codify”?

Stick into the go.mod.

~/src/cloud.google.com/go/logging$ gotip mod tidy

Does this edit the go.mod?

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jun 3, 2019

Does this edit the go.mod?

It does if there are no errors.

@jadekler

This comment has been minimized.

Copy link
Contributor Author

@jadekler jadekler commented Jul 12, 2019

For posterity, from https://code-review.googlesource.com/c/gocloud/+/41530:

You can compute the rest of the dependencies by running go mod edit -replace <parent>@<latest version>=./..; go mod tidy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.