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 directive mutated when run go mod tidy #40429

Closed
slinkydeveloper opened this issue Jul 27, 2020 · 3 comments
Closed

cmd/go: replace directive mutated when run go mod tidy #40429

slinkydeveloper opened this issue Jul 27, 2020 · 3 comments

Comments

@slinkydeveloper
Copy link

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

$ go version
go version go1.14.3 linux/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
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/slinkydeveloper/.cache/go-build"
GOENV="/home/slinkydeveloper/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/slinkydeveloper/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build499797199=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I'm trying to test a personal fork of a dependency in a project, and i'm using the replace directive as follows:

knative.dev/pkg => github.com/slinkydeveloper/pkg serious_port_forwarding

For some reason, when i run go mod tidy to update the deps, the replace directive is mutated replacing it with the actual commit hash

knative.dev/pkg => github.com/slinkydeveloper/pkg v0.0.0-20200724072217-fc14798189e0

which means that every time i update my fork, i need to update the directive and retrigger the update with go mod tidy

What did you expect to see?

replace directive should not mutate. To be precise, I expect them to be immutable in all situations because they're hand made directives to instruct to tool where and which versions of the code to pick

What did you see instead?

replace directive mutates.

@bcmills
Copy link
Contributor

bcmills commented Jul 27, 2020

The go.mod file is intended to provide reproducible builds. A branch that may move is (by definition) not reproducible, so this is working as designed.

@bcmills
Copy link
Contributor

bcmills commented Jul 27, 2020

I think #32721 and #26964 would suffice to allow a replace directive to be upgraded following a branch.

@bcmills bcmills changed the title gomod: replace directive mutated when run go mod tidy cmd/go: replace directive mutated when run go mod tidy Jul 27, 2020
@bcmills
Copy link
Contributor

bcmills commented Jul 27, 2020

Duplicate of #32721

@bcmills bcmills marked this as a duplicate of #32721 Jul 27, 2020
@bcmills bcmills closed this as completed Jul 27, 2020
@golang golang locked and limited conversation to collaborators Jul 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants