cmd/go: `go build` fails to read vcs info when .git is owned by a different user
#53.532 aperta il 24 giu 2022
Metriche repository
- Star
- (133.883 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
What did you do?
tried to build a program with a git repository in root, program stated:
$ sudo make
go build -o cpgov
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
make: *** [Makefile:5: cpgov] Error 1
while running without root works
$ make
go build -o cpgov
$ sudo make install
# successfully installs now that compilation is not happening
example not using Makefile as image:

What did you expect to see?
The program should not fail to grab vcs info (seemingly) just because it is in root instead of the owning user of the git repository (swapping permissions on .git to 777 did not work, swapping owner of .git to root.root did not work).
What did you see instead?
go build outputted a very unhelpful error message that it failed to obtain VCS information for some reason, and left not enough information to even properly understand the scope of this issue, for that reason I do not fully understand the scope of this issue, or even if it is somehow intended behavior.