Does this issue reproduce with the latest release?
Yes, with latest 1.18 (that is, 1.18.3), which is not the latest Go release itself, though
What operating system and processor architecture are you using (go env)?
It's a docker container but reproduces on Apple Silicon and on Debian 10 x86.
What did you do?
I just tried building my image:
docker build --no-cache -f deploy/Dockerfile .
and got output:
> [3/4] RUN go build .:
#7 0.265 error obtaining VCS status: exit status 128
#7 0.265 Use -buildvcs=false to disable VCS stamping.
executor failed running [/bin/sh -c go build .]: exit code: 1
What did you expect to see?
What did you see instead?
So, to make this reproducible, I created a nested git repository because the error does not occur if I remove the nested/.git file. Recursively cloning the repo, cding into nested and then run aforementioned build command reproduces it for me on two systems:
> [4/6] RUN git status:
#8 0.832 fatal: not a git repository: /../.git/modules/nested
I would consider this a git issue (the way it handles git dirs in submodules).
Like #53532 we could return a better error (the git output), but ultimately it would still be up to the user to decide if they want to embed vcs info (provide a complete .git dir) or not (-buildvcs=false or remove the .git file/dir).
If this is the standard layout for a Git submodule, then perhaps we should change vcs.RepoRootForImportPath to detect that configuration and report the root of the parent repo instead of the submodule directory.