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: error if GOCACHE is set but is not an absolute path #30447

Closed
mileusna opened this issue Feb 27, 2019 · 9 comments
Closed

cmd/go: error if GOCACHE is set but is not an absolute path #30447

mileusna opened this issue Feb 27, 2019 · 9 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mileusna
Copy link

mileusna commented Feb 27, 2019

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

$ go version
go version go1.12 darwin/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
GOARCH="amd64"
GOBIN=""
GOCACHE="on"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mileusna/Dropbox/"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/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/3r/3lsskhdx6db_lw1m06qfr62c0000gn/T/go-build512222336=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

# go test

What did you expect to see?

Test running

What did you see instead?

Build error and test failed probably due to new structure for cache directories in 1.12

# devgit.ha.rs/mi2/cmd/mnsinfo-api.test
/var/folders/3r/3lsskhdx6db_lw1m06qfr62c0000gn/T/go-build218744920/b001/_testmain.go:10:2: can't open import: "devgit.ha.rs/mi2/cmd/mnsinfo-api": open on/f9/f95617d4d2ff6b243c4e9e04cf4904cdde38953c391e5a9abb6291e18732b096-d: no such file or directory
FAIL	devgit.ha.rs/mi2/cmd/mnsinfo-api [build failed]
Error: Tests failed.

Executing go clean -cache will fix a problem for a while, but then it starts occurring again.

@mileusna mileusna changed the title cmd/go: go test build error in go 1.12 due to new cache folder cmd/go: go test build error in go 1.12 due to new cache directory structure Feb 27, 2019
@ianlancetaylor
Copy link
Contributor

Don't set GOCACHE=on. GOCACHE should be the path to the cache directory you want to use. We should probably give an error if GOCACHE is set and it is not an absolute path.

@ianlancetaylor ianlancetaylor changed the title cmd/go: go test build error in go 1.12 due to new cache directory structure cmd/go: error if GOCACHE is set but is not an absolute path Feb 27, 2019
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 27, 2019
@ianlancetaylor ianlancetaylor added this to the Go1.12.1 milestone Feb 27, 2019
@mileusna
Copy link
Author

mileusna commented Feb 27, 2019

Thanks, I was wondering why the hell the tmp directory is named "on". 😂

I have an explanation for this. The story goes that I had this settings on "off", but 1.12 didn't want to compile with GOCACHE="off". I try to delete it from .bash_profile but VSCode haven't picked up that change after several VSCode restarts, so I put it back and set it to "on". Compile started to work and I end up with "on/" directory for cache files 😂 but go test started to fail.

@agnivade
Copy link
Contributor

Also see previous conversation here #28290.

@gopherbot
Copy link

Change https://golang.org/cl/164200 mentions this issue: cmd/go/internal/cache: disable builds if GOCACHE is not an absolute path

@mileusna
Copy link
Author

Now when I know for this issue, I don't mind if it will be relative or absolute path. The off value is history now, so I guess I will never use this env var ever again.

But for transition period like now when I upgraded from 1.11 to 1.12 and moved from "off" to "on" 😆 warning on abs path would save me a lot of wasted time. :)

@mileusna
Copy link
Author

mileusna commented Feb 28, 2019

Does anyone know how can I avoid cache in go test now when there is no GOCACHE=off?

--- PASS: TestObjDef (0.02s)
PASS
ok  	devgit.ha.rs/mi2/cmd/mnsinfo-api	(cached)
Success: Tests passed.

@agnivade
Copy link
Contributor

https://golang.org/cmd/go/#hdr-Test_packages

The idiomatic way to disable test caching explicitly is to use -count=1.

@oiooj
Copy link
Member

oiooj commented Mar 1, 2019

@gopherbot please backport to 1.12

@gopherbot
Copy link

Backport issue(s) opened: #30493 (for 1.12).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@golang golang locked and limited conversation to collaborators Feb 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants