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: tests fail without clear reason when /tmp/go.mod exists #26708

Closed
mpx opened this issue Jul 31, 2018 · 3 comments

Comments

Projects
None yet
6 participants
@mpx
Copy link
Contributor

commented Jul 31, 2018

Building the Go compiler at tip (+b294fe9b0a) attempted to fetch dependencies for an unrelated repo (!?) and failed. The actual cause is not particularly obvious when you have forgotten there is a bogus go.mod under /tmp from days before.. 🤔

Several tests create temporary build directories under /tmp and run go build, which then finds the go.mod and attempts to fetch unrelated dependencies. Here is a small excerpt of the log/failures:

[..]
--- FAIL: TestBadImportsEasy (1.40s)
    go_test.go:1012: running testgo [build -o ./easy testdata/#$%:, &()*;<=>?\^{}/easy.go]
    go_test.go:1012: standard error:
    go_test.go:1012: go: github.com/prometheus/client_model@v0.0.0-20150212101744-fa8ad6fec335: lookup github.com/prometheus/client_model: mkdir /test-go-home-does-not-exist: permission denied
[..]
--- FAIL: TestBadImportsEasySub (1.32s)
    go_test.go:1019: running testgo [build -o ./easysub testdata/#$%:, &()*;<=>?\^{}/easysub/main.go]
    go_test.go:1019: standard error:
    go_test.go:1019: go: github.com/prometheus/client_model@v0.0.0-20150212101744-fa8ad6fec335: lookup github.com/prometheus/client_model: mkdir /test-go-home-does-not-exist: permission denied
[..]
--- FAIL: TestBadImportsHard (1.13s)
    go_test.go:1026: running testgo [build -o ./hard testdata/#$%:, &()*;<=>?\^{}/hard.go]
    go_test.go:1026: standard error:
    go_test.go:1026: go: github.com/prometheus/client_model@v0.0.0-20150212101744-fa8ad6fec335: lookup github.com/prometheus/client_model: mkdir /test-go-home-does-not-exist: permission denied
[..]

Perhaps tests should disable fetching modules to avoid loading a bogus /tmp/go.mod?

I think a fix would be useful since /tmp is a fairly common place to put random files (like go.mod) and the errors can burn a bunch time trying to make sense of them. However, I'd understand if it was considered rare enough to ignore.

Thoughts?

@ALTree ALTree changed the title cmd/go: Tests fail without clear reason when /tmp/go.mod exists cmd/go: tests fail without clear reason when /tmp/go.mod exists Jul 31, 2018

@myitcv

This comment has been minimized.

Copy link
Member

commented Jul 31, 2018

/cc @rsc @bcmills

I just happened to run into exactly the same "problem" whilst recreating an issue in temp directories created below /tmp, i.e. /tmp/asdfasdf. I had a rogue /tmp/go.mod kicking around which, unsurprisingly, interfered with my tests.

Now my situation is arguably my own fault, but when it comes to tests/builds etc running within $TMPDIR could this be a wider issue?

@thepudds

This comment has been minimized.

Copy link

commented Aug 7, 2018

@gopherbot, please add label modules

@gopherbot gopherbot added the modules label Aug 7, 2018

@gopherbot

This comment has been minimized.

Copy link

commented Aug 11, 2018

Change https://golang.org/cl/129063 mentions this issue: cmd/go: ignore /tmp/go.mod

@gopherbot gopherbot closed this in c265c89 Aug 17, 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.