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: several commands require the build cache but don't use it #39882

Open
mvdan opened this issue Jun 26, 2020 · 5 comments
Open

cmd/go: several commands require the build cache but don't use it #39882

mvdan opened this issue Jun 26, 2020 · 5 comments
Assignees
Milestone

Comments

@mvdan
Copy link
Member

@mvdan mvdan commented Jun 26, 2020

Steps to repro:

docker run -i golang:1.15beta1 <<-SCRIPT

        set -ex

        go version
        go env

        mkdir /tmp/foo
        cd /tmp/foo
        go mod init test
        go mod edit -go=1.13

        HOME= GOCACHE= go mod edit -go=1.14

SCRIPT

I think this should succeed. go mod edit -go=X only has to modify a line in go.mod, it shouldn't require the build cache to exist or be writeable. However, that last command fails:

+ go mod edit -go=1.14
build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined

I encountered this while writing some tests, which are run in a temporary directory with a near-empty environment (partly to not pollute the user's $HOME and such).

@mvdan
Copy link
Member Author

@mvdan mvdan commented Jun 26, 2020

Err, this is worse than I thought - I can't even do go list -m -json without a writable build cache:

> exec go list -m -json
[stderr]
failed to initialize build cache at /no-home/.cache/go-build: mkdir /no-home: permission denied

What am I missing?

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Jun 29, 2020

Need to add a test case for go mod edit, but I expect CL 236563 will fix this. The new test covers go list -m and a couple other things.

@jayconrod jayconrod added this to the Go1.16 milestone Jun 29, 2020
@jayconrod jayconrod self-assigned this Jun 29, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 30, 2020

Change https://golang.org/cl/240548 mentions this issue: cmd/go/internal/modload: don't initialize build cache

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Jun 30, 2020

CL 236563 fixes a different issue.

I just mailed CL 240548, which should fix this for module commands that don't use the build cache.

There are a number of other commands that probably should work but don't, like go get -d and go list without -export or -compiled. That CL won't fix those, so I'll leave this issue open.

@jayconrod jayconrod changed the title cmd/go: mod edit always requires the build cache to be writeable cmd/go: several commands require the build cache but don't use it Jun 30, 2020
@mvdan
Copy link
Member Author

@mvdan mvdan commented Jun 30, 2020

Neat :) If those other changes would be similarly small enough, perhaps we can label this "help wanted".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.