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 -testcache fails if GOCACHE directory does not exist #29100

Closed
mxk opened this issue Dec 4, 2018 · 7 comments
Closed

cmd/go: go clean -testcache fails if GOCACHE directory does not exist #29100

mxk opened this issue Dec 4, 2018 · 7 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mxk
Copy link

mxk commented Dec 4, 2018

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

$ go version
go version go1.11.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes. It may be affected by #26794 for 1.12, but looking at the code, I think the bug is still there.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN="/Users/mxk/bin"
GOCACHE="/Users/mxk/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mxk/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.2/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/xg/rnkm_hgs5298dsx212f1_y2c0000gp/T/go-build752263492=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

cachedir=$(go env GOCACHE)
mv $cachedir $cachedir.old
go clean -testcache
mv $cachedir.old $cachedir

What did you expect to see?

No errors and an exit code of 0.

What did you see instead?

go clean -testcache: open /Users/mxk/Library/Caches/go-build/testexpire.txt: no such file or directory
exit code 1

The -testcache flag assumes that the cache directory exists. When that's not the case, there is nothing to clear, so the command should exit normally.

@mxk mxk changed the title go clean -testcache fails if GOCACHE directory does not exist cmd/go: go clean -testcache fails if GOCACHE directory does not exist Dec 4, 2018
@agnivade
Copy link
Contributor

agnivade commented Dec 5, 2018

/cc @bcmills

@agnivade agnivade added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Dec 5, 2018
@agnivade agnivade added this to the Go1.13 milestone Dec 5, 2018
@bcmills
Copy link
Contributor

bcmills commented May 29, 2019

I believe this was fixed by #28680. Please reopen if you can still reproduce it at head.

example.com$ gotip env GOCACHE
/tmp/tmp.pCKjol3k6h

example.com$ rm -r $(gotip env GOCACHE)

example.com$ gotip clean -testcache

@bcmills bcmills closed this as completed May 29, 2019
@MatthiasScholz
Copy link

The issue does not seem to be fixed.

Running version:

  • go version go1.13.5 linux/amd64

Gives the following error message:

go clean -testcache
go clean -testcache: open /.../.cache/go-build/testexpire.txt: no such file or directory

@ianlancetaylor
Copy link
Contributor

Yes, I can recreate this if I rename the entire cache directory as the first comment suggests.

@ianlancetaylor ianlancetaylor reopened this Dec 8, 2019
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 8, 2019
@ianlancetaylor ianlancetaylor modified the milestones: Go1.13, Go1.15 Dec 8, 2019
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 8, 2019
MatthiasScholz added a commit to MatthiasScholz/cos that referenced this issue Dec 9, 2019
Trying to find a possible regression, related to issued:
golang/go#29100
MatthiasScholz added a commit to MatthiasScholz/cos that referenced this issue Dec 9, 2019
Trying to find a possible regression, related to issued:
golang/go#29100
MatthiasScholz added a commit to MatthiasScholz/cos that referenced this issue Dec 9, 2019
Trying to find a possible regression, related to issued:
golang/go#29100
MatthiasScholz added a commit to MatthiasScholz/cos that referenced this issue Dec 9, 2019
Trying to find a possible regression, related to issued:
golang/go#29100
MatthiasScholz added a commit to MatthiasScholz/cos that referenced this issue Dec 10, 2019
Trying to find a possible regression, related to issued:
golang/go#29100
@jespino
Copy link

jespino commented Dec 19, 2019

I can work on this.

I would like to confirm something. Is it, no fail and no warning, the expected behavior? Is it a correct assumption that is there is no testexpire.txt file, the test cache is already clean? Do we care about somebody accidentally removing the .cache/go-build/testexpire.txt file, but not the rest of the testcache files?

@bcmills
Copy link
Contributor

bcmills commented Dec 19, 2019

@jespino, I think the error comes from here:

f, err := lockedfile.Edit(filepath.Join(dir, "testexpire.txt"))

lockedfile.Edit creates the file if it does not already exist, so presumably the problem is that the parent directory of the file does not yet exist. If the cache directory does not exist at all, then it is necessarily already clean.

(Actually, that makes the fix pretty trivial — simpler to mail a fix than to explain it here.)

@bcmills bcmills modified the milestones: Go1.15, Go1.14 Dec 19, 2019
@bcmills bcmills self-assigned this Dec 19, 2019
@gopherbot
Copy link

Change https://golang.org/cl/212099 mentions this issue: cmd/go/internal/clean: make 'go clean -testcache' a no-op if the cache directory is gone

MatthiasScholzTW added a commit to MatthiasScholz/cos that referenced this issue May 4, 2020
With the release of go 1.4 the following issue got closed:
- golang/go#29100
MatthiasScholzTW added a commit to MatthiasScholz/cos that referenced this issue May 4, 2020
Moving to new golang version since the following issue got fixed:
- golang/go#29100
@golang golang locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants