Skip to content

cmd/dist: fails with buildvcs=false errors if invalid .git exists in parent of GOROOT_BOOTSTRAP #61620

Description

@paralin

Related: #54852 - cc @williamh @bcmills

In Buildroot we have a build failure when there exists an invalid .git in a parent directory of GOROOT_BOOTSTRAP: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525

Building Go toolchain1 using /builds/buildroot.org/buildroot/test-output/TestMender/host/lib/go-1.19.10.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
go tool dist: FAILED: /builds/buildroot.org/buildroot/test-output/TestMender/host/lib/go-1.19.10/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...: exit status 1

Reproduction of the issue:

# This reproduction sets up a directory structure that breaks Go make.bash.
# make.bash should not break due to .git files outside of the Go sources.
#
# The error specifically occurs when an invalid .git is present in a parent git
# directory of the GOROOT_BOOTSTRAP. Go issue #61620
mkdir go-issue-61620
cd ./go-issue-61620
wget https://go.dev/dl/go1.19.11.src.tar.gz
mkdir go-bootstrap
tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1
cd ./go-bootstrap/src/
bash make.bash
cd ../../
wget https://go.dev/dl/go1.20.6.src.tar.gz
mkdir go
tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1
printf "gitdir: ../../does/not/exist/.git" > ./.git
cd ./go/src/
GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash
# Build fails using -buildvcs=false errors.

The error only occurs when the .git that git detects in the parent directory
of the GOROOT_BOOTSTRAP is invalid or not present causing errors when running git commands within GOROOT_BOOTSTRAP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions