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-ridge opened this issue Aug 23, 2018 · 6 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@misha-ridge
Copy link

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-ridge misha-ridge 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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Aug 23, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Aug 23, 2018
@ianlancetaylor
Copy link
Contributor

CC @bcmills

@groob
Copy link
Contributor

groob 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.

@rsc
Copy link
Contributor

rsc 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
Copy link
Member

myitcv commented Oct 25, 2018

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

@misha-ridge
Copy link
Author

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
Copy link
Member

myitcv commented Nov 13, 2018

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

@myitcv myitcv closed this as completed Nov 13, 2018
@golang golang locked and limited conversation to collaborators Nov 13, 2019
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.
Projects
None yet
Development

No branches or pull requests

6 participants