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: replace directives not helping with dependencies #26841

Closed
swtch1 opened this issue Aug 7, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@swtch1
Copy link

commented Aug 7, 2018

(go version)

go version go1.11beta3 windows/amd64

(go env)

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jxt82ty\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\jxt82ty\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Users\jxt82ty\sdk\go1.11beta3
set GOTMPDIR=
set GOTOOLDIR=C:\Users\jxt82ty\sdk\go1.11beta3\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\tmp\pcf_config_generator\pcfconfgen\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\jxt82ty\AppData\Local\Temp\1\go-build932205774=/tmp/go-build -gno-record-gcc-switches

What did you do?

I tried to resolve dependencies with go mod tidy with a replace statement in the go.mod file.

$ cat go.mod
module github.mycompany.com/proj

require (
        github.com/kubernetes/api v0.0.0-20180806131826-70491ec73e10 // indirect
        github.com/kubernetes/client-go v8.0.0+incompatible // indirect
)

replace k8s.io/client-go => github.com/kubernetes/client-go v8.0.0+incompatible
replace k8s.io/client-go/pkg/api => github.com/kubernetes/client-go/pkg/api v8.0.0+incompatible
replace k8s.io/client-go/pkg/apis/extensions/v1beta1 => github.com/kubernetes/api/extensions/v1beta1 v0.0.0-20180806131826-70491ec73e10

What did you expect to see?

I expected for the replacement to assist in resolving the dependencies.

What did you see instead?

$ go mod tidy
~~~
go: import "pcf_config_generator/pcfconfgen/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/kubernetes" ->
        import "k8s.io/client-go/pkg/api": cannot find module providing package k8s.io/client-go/pkg/api
go: import "pcf_config_generator/pcfconfgen/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/kubernetes" ->
        import "k8s.io/client-go/pkg/api/v1": cannot find module providing package k8s.io/client-go/pkg/api/v1
go: import "pcf_config_generator/pcfconfgen/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/kubernetes" ->
        import "k8s.io/client-go/pkg/apis/extensions/v1beta1": cannot find module providing package k8s.io/client-go/pkg/apis/extensions/v1beta1

@swtch1 swtch1 changed the title go1.11beta3 Replace Not Working As Expected cmd/go: go1.11beta3 Replace Not Working As Expected Aug 7, 2018

@ianlancetaylor ianlancetaylor changed the title cmd/go: go1.11beta3 Replace Not Working As Expected cmd/go: replace directives not helping with dependencies Aug 7, 2018

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Aug 7, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2018

@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 7, 2018

Duplicate of #26241, or possibly #26602?

@rsc

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2018

I'm not sure how you got into this state so I'm not quite sure what the go command should do to help. For the record, I think the go.mod you want is simply:

module github.mycompany.com/proj

require (
    k8s.io/api v0.0.0-20180806131826-70491ec73e10 
    k8s.io/client-go v8.0.0+incompatible
)

"go get" has always understood that k8s.io/client-go comes from github, because the <meta> tags on https://k8s.io/client-go?go-get=1 say so. So you don't need to try to explain that fact in the go.mod.

@rsc rsc modified the milestones: Go1.11, Go1.12 Aug 10, 2018

@swtch1

This comment has been minimized.

Copy link
Author

commented Aug 10, 2018

I got there after many frustrating attempts to correct the solve in dep, which I believed to involve constraints that used a different source repo.

These are the important bits of my go mod tidy failure

~~~
go: import "github.mycompany.com/proj/log" ->
        import "github.com/sirupsen/logrus" ->
        import "golang.org/x/crypto/ssh/terminal": cannot find module providing package golang.org/x/crypto/ssh/terminal
go: import "github.mycompany.com/proj/log" ->
        import "github.com/sirupsen/logrus" ->
        import "golang.org/x/sys/unix": cannot find module providing package golang.org/x/sys/unix
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/azure" ->
        import "github.com/Azure/azure-sdk-for-go/arm/compute": cannot find module providing package github.com/Azure/azure-sdk-for-go/arm/compute
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/azure" ->
        import "github.com/Azure/azure-sdk-for-go/arm/network": cannot find module providing package github.com/Azure/azure-sdk-for-go/arm/network
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/gce" ->
        import "golang.org/x/oauth2": cannot find module providing package golang.org/x/oauth2
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/gce" ->
        import "golang.org/x/oauth2/google": cannot find module providing package golang.org/x/oauth2/google
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/gce" ->
        import "google.golang.org/api/compute/v1": cannot find module providing package google.golang.org/api/compute/v1
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/kubernetes" ->
        import "k8s.io/client-go/pkg/api": cannot find module providing package k8s.io/client-go/pkg/api
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/kubernetes" ->
        import "k8s.io/client-go/pkg/api/v1": cannot find module providing package k8s.io/client-go/pkg/api/v1
go: import "github.mycompany.com/proj/prometheus/promcfg" ->
        import "github.com/prometheus/prometheus/discovery/config" ->
        import "github.com/prometheus/prometheus/discovery/kubernetes" ->
        import "k8s.io/client-go/pkg/apis/extensions/v1beta1": cannot find module providing package k8s.io/client-go/pkg/apis/extensions/v1beta1
@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 10, 2018

All of those failures look like #26602, which is fixed at head. Could you try building the go tool from source and see if you're still having trouble?

@swtch1

This comment has been minimized.

Copy link
Author

commented Aug 14, 2018

modules are amazing. Updated go from master fulfills all of my dependencies correctly and super fast, with no special configuration. Thank you.

@swtch1 swtch1 closed this Aug 14, 2018

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