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: document .lock files in the module cache #51121

Open
kasvtv opened this issue Feb 9, 2022 · 5 comments
Open

cmd/go: document .lock files in the module cache #51121

kasvtv opened this issue Feb 9, 2022 · 5 comments
Labels
Documentation GoCommand cmd/go help wanted modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@kasvtv
Copy link

kasvtv commented Feb 9, 2022

.lock files in the go modules cache are a frequent source of issues for us. Take the following common use case for example: when running go in a Docker container that has had dependencies installed into it as part of building the Docker image, these dependencies are naturally owned by root with 755 permissions.

However, when running go build in the container, naturally, the user is no longer root at this time, and one sees frequent issues in the form of:

../cmd/app/main.go:6:2: open /go/pkg/mod/cache/download/github.com/<user>/<repo>/@v/v1.9.0.lock: permission denied

because the root-owned file is obviously not writable to the user.

I was very surprised to see there was no documentation of this type of file available anywhere. I would like to suggest that, for example this page would explain the purpose and functioning of these files, to provide insight into errors such as these, so they can be resolved. Alternatively, I would also welcome a suggested workflow change, to make these files no longer a problem, such that they can stay implementation details that can be disregarded by the user.

@kasvtv kasvtv added the Proposal label Feb 9, 2022
@ianlancetaylor
Copy link
Contributor

Thanks for the report. This does't need to be a proposal, so taking it out of the proposal process.

@ianlancetaylor ianlancetaylor changed the title proposal: provide documentation for .lock files cmd/go: document .lock files in the module cache Feb 9, 2022
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Feb 9, 2022
@ianlancetaylor
Copy link
Contributor

CC @bcmills

@beoran
Copy link

beoran commented Feb 9, 2022

To solve this problem it is possible to set to GOCACHE environment variable to a path that is writable by the non root user that runs the go compiler. Maybe this should be documented more.

@kasvtv
Copy link
Author

kasvtv commented Feb 10, 2022

To solve this problem it is possible to set to GOCACHE environment variable to a path that is writable by the non root user that runs the go compiler. Maybe this should be documented more.

Unfortunately this does not seem to have an effect on the lockfile. For example, if I add:

ENV GOCACHE=/tmp/gocache

To the very top of my Dockerfile, while I do get caching data in that directory:

/app $ ls /tmp/gocache
00        0f        1e        2d        3c        4b        5a        69        78        87        96        a4        b3        c2        d1        e0        ef        fe
01        10        1f        2e        3d        4c        5b        6a        79        88        97        a5        b4        c3        d2        e1        f0        ff
02        11        20        2f        3e        4d        5c        6b        7a        89        98        a6        b5        c4        d3        e2        f1        trim.txt
03        12        21        30        3f        4e        5d        6c        7b        8a        99        a7        b6        c5        d4        e3        f2
04        13        22        31        40        4f        5e        6d        7c        8b        9a        a8        b7        c6        d5        e4        f3
05        14        23        32        41        50        5f        6e        7d        8c        9b        a9        b8        c7        d6        e5        f4
06        15        24        33        42        51        60        6f        7e        8d        9c        aa        b9        c8        d7        e6        f5
07        16        25        34        43        52        61        70        7f        8e        9d        ab        ba        c9        d8        e7        f6
08        17        26        35        44        53        62        71        80        8f        9e        ac        bb        ca        d9        e8        f7
09        18        27        36        45        54        63        72        81        90        9f        ad        bc        cb        da        e9        f8
0a        19        28        37        46        55        64        73        82        91        README    ae        bd        cc        db        ea        f9
0b        1a        29        38        47        56        65        74        83        92        a0        af        be        cd        dc        eb        fa
0c        1b        2a        39        48        57        66        75        84        93        a1        b0        bf        ce        dd        ec        fb
0d        1c        2b        3a        49        58        67        76        85        94        a2        b1        c0        cf        de        ed        fc
0e        1d        2c        3b        4a        59        68        77        86        95        a3        b2        c1        d0        df        ee        fd

I still get the same error about the same lockfile in the same path.

@beoran
Copy link

beoran commented Feb 10, 2022

Ah sorry, you will also have to set GOMODCACHE. See #34527

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation GoCommand cmd/go help wanted modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants