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 vendor some replace pkg didn't inside vendor #28633

Closed
lizihuai opened this issue Nov 7, 2018 · 7 comments
Closed

cmd/go: go mod vendor some replace pkg didn't inside vendor #28633

lizihuai opened this issue Nov 7, 2018 · 7 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@lizihuai
Copy link

lizihuai commented Nov 7, 2018

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

$ go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env

What did you do?

GO111MODULE=on go mod download
GO111MODULE=on go mod vendor

I use "replace" in go.mod file . like replace golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac => github.com/golang/crypto v0.0.0-20180820150726-614d502a4dac use go mod download ,downloaded package in “src/pkg” directory , but when use go mod vendor some pkg didn't inside the vendor

What did you expect to see?

What did you see instead?

@ianlancetaylor ianlancetaylor changed the title go mod vendor some replace pkg didn't inside vendor cmd/go: go mod vendor some replace pkg didn't inside vendor Nov 7, 2018
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Nov 7, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Nov 7, 2018
@ianlancetaylor
Copy link
Contributor

CC @bcmills

@bcmills
Copy link
Contributor

bcmills commented Nov 7, 2018

when use go mod vendor some pkg didn't inside the vendor

I don't know what that means. Please provide explicit steps that we can follow exactly to reproduce the problem, ideally starting from an empty directory.

Note that go mod vendor “[includes] all packages needed to build and test all the main module's packages”, not all packages from the modules needed to build and test the main module. Packages that are not needed to build the main module are not vendored.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 7, 2018
@lizihuai
Copy link
Author

lizihuai commented Nov 8, 2018

for example ,go.mod like (fake code)

module github.com/lizihuai/test

require (
golang.org/x/net v0.0.0-20180824152047-4bcd98cce591
google.golang.org/grpc v1.14.0
k8s.io/api v0.0.0-20180925152912-a191abe0b71e // indirect
k8s.io/apimachinery v0.0.0-20180823151430-017bf4f8f588
)

replace (
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac => github.com/golang/crypto v0.0.0-20180820150726-614d502a4dac
golang.org/x/net v0.0.0-20180824152047-4bcd98cce591 => github.com/golang/net v0.0.0-20180824152047-4bcd98cce591
golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87 => github.com/golang/sys v0.0.0-20180824143301-4910a1d54f87
golang.org/x/text v0.3.0 => github.com/golang/text v0.3.0
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 => github.com/golang/time v0.0.0-20180412165947-fbb02b2291d2
)

use go mod download be downloaded no matter what use requireor or replace but go mod vendor some pkg not inside " vendor" , like "golang.org/x/sys" (the project use all of the above packages)

@bcmills
Copy link
Contributor

bcmills commented Nov 9, 2018

Please provide explicit steps that we can follow exactly to reproduce the problem, ideally starting from an empty directory.

go mod vendor uses the import graph of the actual Go source files to decide what to copy. To diagnose the problem, we need at least enough of the source files to capture that import graph.

Note that go mod why -m -vendor can tell you whether or why a given module should be present in vendor.

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 16, 2018
@ibalajiarun
Copy link

ibalajiarun commented Apr 18, 2019

I have a similar issue. Let say I have a go.mod like below, where I want to use my fork of go.etcd.io/etcd at gitlab.com

module gitlab.com/user/go-raft-kv

go 1.12

replace go.etcd.io/etcd => gitlab.com/user/etcd v0.0.0-20190418142634-07789e37997a

require (
	github.com/gogo/protobuf v1.2.1
	github.com/golang/protobuf v1.3.1 // indirect
	github.com/pkg/errors v0.8.1
	github.com/spf13/pflag v1.0.3
	go.etcd.io/etcd v3.3.12+incompatible
	golang.org/x/net v0.0.0-20190415214537-1da14a5a36f2
	google.golang.org/grpc v1.20.0
)

My main.go file imports "go.etcd.io/etcd/raft" and uses it. When I go mod vendor, go.etcd.io is downloaded into vendor and not 'gitlab.com/user/etcd'. Doesn't vendor respect replace?

@ibalajiarun
Copy link

My bad. It works, but uses the same module name as the original. That confused me. Sorry about that.

@agnivade agnivade added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 25, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants