Skip to content

cmd/go: "go test" seems to now require git due to -buildvcs #51723

@mvdan

Description

@mvdan
go version go1.18 linux/amd64

I have a CI job that runs go test ./... in a git clone, but inside a Docker image where git isn't installed. This worked fine in Go 1.17.x, but breaks with 1.18 unless I add -buildvcs=false.

Reproducer:

#!/bin/bash

docker run -i golang:1.18-alpine <<-SCRIPT

	set -ex

	go version

	apk update
	apk add git

	git clone --depth=1 https://github.com/mvdan/sh
	cd sh

	apk del git

	go test ./...

SCRIPT

Output:

[...]
+ go test ./...
go: downloading github.com/google/renameio v1.0.1
go: downloading github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
go: downloading golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
go: downloading mvdan.cc/editorconfig v0.2.0
go: downloading github.com/rogpeppe/go-internal v1.8.1
go: downloading golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
go: downloading golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
go: downloading github.com/creack/pty v1.1.17
go: downloading github.com/frankban/quicktest v1.14.0
go: downloading github.com/google/go-cmp v0.5.6
go: downloading gopkg.in/errgo.v2 v2.1.0
go: downloading github.com/kr/pretty v0.3.0
go: downloading github.com/kr/text v0.2.0
go: missing Git command. See https://golang.org/s/gogetcmd
error obtaining VCS status: exec: "git": executable file not found in $PATH
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exec: "git": executable file not found in $PATH
	Use -buildvcs=false to disable VCS stamping.

I tried to reproduce this with a dummy module and no dependencies, even creating a dummy git repository, but all of that worked. So I imagine it has something to do with the dependencies. Note that the dependencies here are all downloaded from GOPROXY, so no VCS is needed.

cc @bcmills @matloob

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions