-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: leave $GOPATH/pkg/mod directories writable (removable) #27161
Comments
https://tip.golang.org/cmd/go/#hdr-Remove_object_files_and_cached_files
|
Interesting, I wasn't aware of that command. I think most folks are more familiar with |
Read-only modules are useful to add friction to local modifications which cause "works on my machine" issues (which I'm often guilty of in Python for example). However, we'd probably get most of the benefit by just marking the files read-only, and not the folders, such that modifying files still fails but removing them succeeds.
vs
|
So if my understanding is correct, everything should be acceptable if we had the directories within the |
This would work for me. |
Paging @rsc for a decision on this. Other folks are stumbling on this too. What do you think of @FiloSottile's suggestion ? |
I am still concerned that "write a temp file and mv it into the target file" will succeed at the system call level unless the directory is marked read-only (that's definitely true). It may be that all the popular editors that use this trick are also smart enough to check the writability of the target file themselves. I am also very surprised that rm -r is somehow too dumb to do the right thing. But fine, we can leave the directories writable to make up for rm -r's inadequacy. |
I remembered the other reason the directories are unwritable. Tests are by definition run in the directory containing the source code for the package, so that they can access testdata directories as relative paths, and so on. But we absolutely do not want tests to be writing in those directories. Marking the directory unwritable is how we ensure that. |
Working as intended. Will not change directories to be writable. |
I'd like to object to this. Making them temporarily unwritable during tests seems fine, but leaving it that way is pretty silly.
via #27455 No, it's really not. People don't go around rm -r'ing things unless they mean to, and even so - it's just a cache. It's not important. |
Go modules writes a bunch of stuff in $GOPATH/pkg/mod as read-only. Standard rm -rf throws an error when it encounters read-only files. So find the files that are read-only and make them not read-only. See also: golang/go#27161
Argument that a bad idea is how it was intended is what drags people away from golang. You say some useless usecase about preventing tests write somewhere something. We will take care of that when we care or when that rare situation occurs. On the other hand CI is a very common use case that people have to deal with deleting your files. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Go modules writes a bunch of stuff in $GOPATH/pkg/mod as read-only. Standard rm -rf throws an error when it encounters read-only files. So find the files that are read-only and make them not read-only. See also: golang/go#27161
The most stupid thing I ever seen. From when developers decide how users should keep their files on their own machine? |
@Perlovka, please bear in mind our Gopher values, and note the further discussion (and resolution) on #31481. |
@bcmills This resolution does not help if you use the stable releases, guess why. One year and half to get option to disable such a "feature", just wow.
Looks like Gopher values working one way only, because such behavior is a cynic disrespect of user opinions. |
An update on this. As of golang 1.14, there is now the option
This solved the issue where my CI pipelines would fail their cleanup because pkg contents were readonly. |
Files downloaded by 'go mod' are not writable (removable). Use the recommended way of cleaning modules [1] [1] golang/go#27161 (comment) Signed-off-by: Adrian Moreno <[email protected]>
Files downloaded by 'go mod' are not writable (removable). Use the recommended way of cleaning modules [1] [1] golang/go#27161 (comment) Signed-off-by: Adrian Moreno <[email protected]>
Files downloaded by 'go mod' are not writable (removable). Use the recommended way of cleaning modules [1] [1] golang/go#27161 (comment) Signed-off-by: Adrian Moreno <[email protected]>
Files downloaded by 'go mod' are not writable (removable). Use the recommended way of cleaning modules [1] [1] golang/go#27161 (comment) Signed-off-by: Adrian Moreno <[email protected]>
|
@bish0polis, please bear in mind our Gopher values, and note the further discussion (and resolution) on #31481. |
Thanks for the link to 31481. Please tell the code I'm sorry for calling it naive. It's a bad hold-over from the USL folks. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yeap
What operating system and processor architecture are you using (
go env
)?What did you do?
I tried to do
rm -r $GOPATH/pkg/mod
to reset my modules cache. It failed with a permissions error. Write permission bit is not set. Evenrm -rf
does not work.Steps to reproduce:
What did you expect to see?
The
$GOPATH/pkg/mod
dir should be deleted.What did you see instead?
It wasn't.
The text was updated successfully, but these errors were encountered: