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 tidy" removes an entry added to go.sum by "go build" for a replacement module #27176

Closed
misha-tectonic opened this issue Aug 23, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@misha-tectonic
Copy link

commented Aug 23, 2018

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

1.11rc2

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dottedmag/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dottedmag/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/dottedmag/kobold/deps/go1.11rc2.darwin-amd64/dist"
GOTMPDIR=""
GOTOOLDIR="/Users/dottedmag/kobold/deps/go1.11rc2.darwin-amd64/dist/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dottedmag/tmp/foo/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/mt/1tmwnxv96cg2vl1nz74_c9cm0000gn/T/go-build168050972=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Added a replace directive for a module.

go build adds an entry for this replacement module to go.sum.
go mod tidy removes the entry from this replacement module.

Reproducer: https://github.com/misha-tectonic/go-mod-tidy-remove-replace-sum

Try go build ., see go.sum changed, then go mod tidy.

What did you expect to see?

go mod tidy does not remove entries added by go build .

What did you see instead?

go mod tidy removes entries added by go build ..

@misha-tectonic misha-tectonic changed the title cmd/go: "go mod fix" removes an entry added to go.sum by "go build" for a replacement module cmd/go: "go mod tidy" removes an entry added to go.sum by "go build" for a replacement module Aug 23, 2018

@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Aug 23, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2018

@groob

This comment has been minimized.

Copy link
Contributor

commented Sep 7, 2018

Seeing this in two separate projects that have a replace directive as well.

edit: running go mod tidy before a commit is an acceptable workaround for now.

lastzero added a commit to photoprism/photoprism that referenced this issue Oct 21, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 24, 2018

Thanks for the repository for use in reproducing the problem. Even when you send such a repo, though, it is very helpful to also send a transcript with exact commands and outputs that you are seeing. It may well be that we run with a slightly different version of the tools or a different environment and don't get the same behavior, and we'd have no way of knowing. So please be more precise in the "what did you see" answer.

@myitcv

This comment has been minimized.

Copy link
Member

commented Oct 25, 2018

This issue is probably related to/dup of #27868. There is a repro listed in #27868 (comment)

@misha-tectonic

This comment has been minimized.

Copy link
Author

commented Oct 28, 2018

Here you go:

% git diff
% go build .
% git diff
diff --git a/go.sum b/go.sum
index cd08da9..cad6fad 100644
--- a/go.sum
+++ b/go.sum
@@ -24,6 +24,7 @@ github.com/jmhodges/levigo v0.0.0-20161115193449-c42d9e0ca023 h1:y5P5G9cANJZt3MX
 github.com/jmhodges/levigo v0.0.0-20161115193449-c42d9e0ca023/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/misha-tectonic/iavl v0.9.3 h1:40j1x7QKAOXYqFm23l8cG/A0XvCqTPG/cemyRA6Ocec=
 github.com/misha-tectonic/iavl v0.9.3/go.mod h1:Tyg8i/tms/Cp33OZdedoyahF09y7l9wxHM2JC3m7Jbo=
 github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
% go mod tidy
% git diff
%
@myitcv

This comment has been minimized.

Copy link
Member

commented Nov 13, 2018

I'm going to close this as a dup of #27868

@myitcv myitcv closed this Nov 13, 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.