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
Closed

cmd/go: tests fail without clear reason when /tmp/go.mod exists #26708

mpx opened this issue Jul 31, 2018 · 3 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@mpx
Copy link
Contributor

mpx 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 added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 31, 2018
@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
Copy link
Member

myitcv 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
Copy link
Contributor

thepudds commented Aug 7, 2018

@gopherbot, please add label modules

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Aug 17, 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. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

6 participants