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: go list creates read-only module cache #30502

Closed
nim-nim opened this issue Mar 1, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@nim-nim
Copy link

commented Mar 1, 2019

$ go version
go version go1.12 linux/amd64
$ rm -fr ~/go/
$ go list -json ./...
go: finding …
go: downloading …
go: extracting …
$ rm -fr ~/go/
rm: cannot remove '…/go/pkg/mod/…': Permission denied

$ ls -l ~/go/pkg/mod/*/*
total …
…/go/pkg/mod/…/…/:
dr-x------. …

$ chmod u+w -R ~/go/
$ rm -fr ~/go/
$

go list should not create files that the user can not remove without permission surgery, that's user-hostile behaviour.

@ALTree

This comment has been minimized.

Copy link
Member

commented Mar 1, 2019

Thanks for reporting this.

This is a dup of #27161 and #27455. In particular, note (from these issues):

Use $ go clean -modcache

Final decision was not to make the cache writable: #27161 (comment). Rationale was given on both of the issues I liked above.

Closing here, since it's a dup and the cache is working as intended.

@ALTree ALTree closed this Mar 1, 2019

@ALTree ALTree changed the title go list creates read-only module cache cmd/go: go list creates read-only module cache Mar 1, 2019

@ALTree ALTree added the modules label Mar 1, 2019

@nim-nim

This comment has been minimized.

Copy link
Author

commented Mar 1, 2019

Well, that's nasty annoying behaviour, that go maintainers find reasonable only because they are go maintainers, and would not accept in other programs.

@ALTree

This comment has been minimized.

Copy link
Member

commented Mar 1, 2019

I'm not sure I understand why this is so problematic.

As is explained in the issues I linked, the go commands require the cache to be in a consistent state, and the cache directories are made not writable to avoid accidental (and deliberate) corruption of the cache structure (for example when using rm on it). This shouldn't be an issue, since there's a specific command (go clean -modcache) that knows how to clean out the cache without causing issues for the other go tools.

Why can't you use go clean -modcache to act (destructively) on the cache?

@nim-nim

This comment has been minimized.

Copy link
Author

commented Mar 1, 2019

Having a situation, where apps start creating files that can not be managed by regular system utilities with their usual options, requiring the use of app-specific commands, that may not even be available on-system anymore (because cache files are kept on-disk when commands are removed), is management hell (for humans and automated housekeeping utilities).

Just list all the files in your home directory and ask yourself if you want to learn one app-specific command per app creator for basic housekeeping like removing stale/cache files.

Besides, rm has clear simple unsurprising semantics, while go clean -modcache is too clever by half and has been known to have unexpected side effects.

@nim-nim

This comment has been minimized.

Copy link
Author

commented Mar 1, 2019

(and I understand the wish to force projects that got used to do very weird and brittle stuff in their unit tests to clean up their act, but creating read-only cache files by default is not a good way to achieve this)

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.