Skip to content
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: tip build failure on Windows when using Mercurial VCS #49841

Closed
gjmct opened this issue Nov 29, 2021 · 6 comments
Closed

cmd/go: tip build failure on Windows when using Mercurial VCS #49841

gjmct opened this issue Nov 29, 2021 · 6 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows release-blocker
Milestone

Comments

@gjmct
Copy link

gjmct commented Nov 29, 2021

What version of Go are you using (go version)?

go version devel go1.18-1ea4d3b Mon Nov 29 00:58:50 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

No

What operating system and processor architecture are you using (go env)?

go env Output
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\gavinm\AppData\Local\go-build
set GOENV=C:\Users\gavinm\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\gavinm\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\gavinm\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\gavinm\AppData\Local\Temp\go-build401408008=/tmp/go-build -gno-record-gcc-switches

What vcs version and extensions are you running?

hg version -v Output
Mercurial Distributed SCM (version 5.9.2)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2021 Olivia Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Enabled extensions:

convert internal
gpg internal
hggit external 0.10.2 (dulwich 0.19.16)
histedit internal
purge internal
rebase internal
strip internal

What did you do?

gotip build

What did you expect to see?

A successful build

What did you see instead?

gotip build -v
error obtaining VCS status: exit status 255
        Use -buildvcs=false to disable VCS stamping
gotip build -v
# cd C:\Users\gavinm\Go\src\quoi.nz\jei\qrtime; hg log -l1 -T {node}:{date(date,"%s")}
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]
** Mercurial Distributed SCM (version 5.9.2)
** Extensions loaded: convert, gpg, hggit 0.10.2 (dulwich 0.19.16), histedit, purge, rebase, strip
Traceback (most recent call last):
  File "hg", line 58, in 
  File "mercurial\dispatch.pyo", line 144, in run
  File "mercurial\dispatch.pyo", line 250, in dispatch
  File "mercurial\dispatch.pyo", line 294, in _rundispatch
  File "mercurial\dispatch.pyo", line 470, in _runcatch
  File "mercurial\dispatch.pyo", line 480, in _callcatch
  File "mercurial\scmutil.pyo", line 153, in callcatch
  File "mercurial\dispatch.pyo", line 460, in _runcatchfunc
  File "mercurial\dispatch.pyo", line 1274, in _dispatch
  File "mercurial\dispatch.pyo", line 918, in runcommand
  File "mercurial\dispatch.pyo", line 1285, in _runcommand
  File "mercurial\dispatch.pyo", line 1271, in 
  File "mercurial\util.pyo", line 1886, in check
  File "mercurial\commands.pyo", line 4735, in log
  File "mercurial\logcmdutil.pyo", line 1231, in displayrevs
  File "mercurial\logcmdutil.pyo", line 303, in show
  File "mercurial\logcmdutil.pyo", line 631, in _show
  File "mercurial\templater.pyo", line 1094, in render
  File "mercurial\util.pyo", line 1796, in increasingchunks
  File "mercurial\templateutil.pyo", line 868, in flatten
  File "mercurial\templateutil.pyo", line 1072, in runtemplate
  File "mercurial\templateutil.pyo", line 921, in evalrawexp
  File "mercurial\templatefuncs.pyo", line 73, in date
  File "mercurial\utils\dateutil.pyo", line 128, in datestr
ValueError: Invalid format string
error obtaining VCS status: exit status 255
        Use -buildvcs=false to disable VCS stamping.

Line 128 in dateutil.pyo is an attempt to parse a date format template. Working backwards into the Go code, the problem seems to be this line in vcs.go:

func hgStatus(vcsHg *Cmd, rootDir string) (Status, error) {
	// Output changeset ID and seconds since epoch.
	out, err := vcsHg.runOutputVerboseOnly(rootDir, `log -l1 -T {node}:{date(date,"%s")}`)

Which I think is caused because "%s" isn't a recognised time format directive.

Changing the line to

	out, err := vcsHg.runOutputVerboseOnly(rootDir, `log -l1 -T {node}:{word(0, date|hgdate)}`)

corrects the issue on my system, but I'm not 100% sure that this is what the expected output for this function should be. Especially as I'm not even passing fluent in Python.

@ALTree ALTree changed the title gotip build failure when using Mercurial VCS cmd/go: tip build failure when using Mercurial VCS Nov 29, 2021
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 29, 2021
@ALTree ALTree added this to the Go1.18 milestone Nov 29, 2021
@ALTree
Copy link
Member

ALTree commented Nov 29, 2021

cc @bcmills

@mpx
Copy link
Contributor

mpx commented Jan 22, 2022

I've tested Mercurial with the buildvcs functionality from v6.0.1 (2021-11-26) back to v3 (2014-05-01). v2 breaks since -T is missing. However, I didn't test Windows. It looks like the strftime format string isn't supported under Windows:

> hg log -l1 -T {node}:{date(date,"%s")}
hg: parse error at 18: not a prefix: %
({node}:{date(date,%s)}
                   ^ here)

UPDATE: I'll send through a patch that removes the filter breaking compatibility.

@ALTree Can you please change the title to reference Windows? (I can't edit it myself)

@gopherbot
Copy link

Change https://golang.org/cl/380077 mentions this issue: cmd/go: fix retriving Mercurial build timestamp under Windows

@mpx
Copy link
Contributor

mpx commented Jan 22, 2022

Can the VCS tools be installed on the Windows builder?

It would help catch this sort of incompatibility in future.

@bcmills bcmills changed the title cmd/go: tip build failure when using Mercurial VCS cmd/go: tip build failure on Windows when using Mercurial VCS Jan 24, 2022
@bcmills
Copy link
Member

bcmills commented Jan 24, 2022

Can the VCS tools be installed on the Windows builder?

They don't even have a working git at the moment. 😞

(Added a comment on #46693.)

@bcmills
Copy link
Member

bcmills commented Jan 26, 2022

This is a release-blocker because build stamping is new as of Go 1.18 and we have a contributed fix CL anyway.

Given the narrowness of the affected platform (Windows + hg) and the availability of -buildvcs=false as a workaround, this does not need to block the next beta release.

@bcmills bcmills added the GoCommand cmd/go label Jan 26, 2022
@bcmills bcmills self-assigned this Jan 26, 2022
jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
Use "hgdate" since the strftime filter is unsupported by Mercurial under
Windows.

Fixes golang#49841

Change-Id: I300898e51e324147aaf1bfe12ed17dea4bdd183d
Reviewed-on: https://go-review.googlesource.com/c/go/+/380077
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Jeremy Faller <jeremy@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
@rsc rsc unassigned bcmills Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants