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 clean -modcache should not download modules #36798

Closed
perillo opened this issue Jan 27, 2020 · 5 comments
Closed

cmd/go: go clean -modcache should not download modules #36798

perillo opened this issue Jan 27, 2020 · 5 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

@perillo
Copy link
Contributor

perillo commented Jan 27, 2020

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

$ go version
go version go1.14beta1 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="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOENV="/home/manlio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY="github.com/perillo"
GONOSUMDB="github.com/perillo"
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go"
GOPRIVATE="github.com/perillo"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/manlio/sdk/go1.14beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/manlio/sdk/go1.14beta1/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-build740722259=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.14beta1 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.14beta1
uname -sr: Linux 5.4.15-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.30.
gdb --version: GNU gdb (GDB) 8.3.1

What did you do?

From inside an empty module (a directory with a go.mod file but no .go source files:

go clean -modcache -n github.com/perillo/i3workon

What did you expect to see?

I was expecting to see only the commands used to remove the module cache.

What did you see instead?

go: downloading github.com/perillo/i3workon v0.3.0
go: downloading golang.org/x/tools v0.0.0-20200115044656-831fdb1e1868
cd /home/manlio/.local/lib/go/pkg/mod/github.com/perillo/[email protected]
rm -f [email protected] [email protected] [email protected] [email protected] main main.exe
rm -rf /home/manlio/.local/lib/go/pkg/mod

go clean is downloading the module, since it is not present in the cache, and then removing it.

There is also something strange with the commands go clean is using.
If, in the end, it is going to remove the entire $GOPATH/pkg/mod directory, what's the use of first trying to remove the specified package first?

I also don't really understand what

is trying to do.
These files do not exist.

@perillo
Copy link
Contributor Author

perillo commented Jan 27, 2020

After having seen the output of go clean -modcache -n -r github.com/perillo/iworkon, it seems that the go clean command thinks that its cleaning a newly built go distribution.

@perillo
Copy link
Contributor Author

perillo commented Jan 27, 2020

I think go clean -modcache <modpath> should only remove all the versions of <modpath> from the module cache, instead of cleaning the entire module cache.

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Jan 27, 2020
@bcmills bcmills added this to the Unplanned milestone Jan 27, 2020
@bcmills
Copy link
Contributor

bcmills commented Jan 27, 2020

go clean is unfortunately pretty overloaded. (See https://tip.golang.org/cmd/go/#hdr-Remove_object_files_and_cached_files for the full details.)

#28835 proposes a -m flag to tell go clean to remove only the requested module, which is semantically different from the meaning of package arguments to go clean today.

CC @jayconrod @matloob

@bcmills
Copy link
Contributor

bcmills commented Jan 27, 2020

#32976 is a more focused request for module arguments to go clean.

@bcmills
Copy link
Contributor

bcmills commented Jan 27, 2020

Duplicate of #32977

@bcmills bcmills marked this as a duplicate of #32977 Jan 27, 2020
@bcmills bcmills closed this as completed Jan 27, 2020
@golang golang locked and limited conversation to collaborators Jan 26, 2021
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

3 participants