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: test -coverprofile "path too long" error on Windows #60785

Closed
chrisdutz opened this issue Jun 14, 2023 · 10 comments
Closed

cmd/go: test -coverprofile "path too long" error on Windows #60785

chrisdutz opened this issue Jun 14, 2023 · 10 comments
Assignees

Comments

@chrisdutz
Copy link

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

$ go version

go version go1.20.5 windows/amd64

Does this issue reproduce with the latest release?

I am on the latest release

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

go env Output
$ go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\cdutz\AppData\Local\go-build
set GOENV=C:\Users\cdutz\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\cdutz\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\cdutz\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\cdutz.mvnGoLang\go1.20.5.windows-amd64
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\cdutz.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\cdutz\AppData\Local\Temp\go-build1515085630=/tmp/go-build -gno-record-gcc-switches

What did you do?

We are using go in the Apache PLC4X project in the plc4go sub-project.
When running our build in our CI/CD servers, the Windows builds are failing when running the tests with coverage:

[WARNING] ---------Exec.Err--------- [WARNING] github.com/apache/plc4x/plc4go/protocols/cbus/readwrite/model: C:\Users\cdutz\.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64\cover.exe: fork/exec C:\Users\cdutz\.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64\cover.exe: Der Dateiname oder die Erweiterung ist zu lang.

Path length is too long (Got a German Windows)

So even when executing the command:

go test -v -coverprofile=target/coverage.out ./...

I'm getting the same error, so it's not related to the maven plugin, that we are using.
I even tried moving Go to "C:\Go" but this too didn't help.

For now we're just disabling go coverage on all windows machines, but we'd like to enable it again.

What did you expect to see?

I would expect the build to not fail on windows

What did you see instead?

[WARNING] ---------Exec.Err--------- [WARNING] github.com/apache/plc4x/plc4go/protocols/cbus/readwrite/model: C:\Users\cdutz\.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64\cover.exe: fork/exec C:\Users\cdutz\.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64\cover.exe: Der Dateiname oder die Erweiterung ist zu lang.

sruehl added a commit to apache/plc4x that referenced this issue Jun 14, 2023
@sruehl
Copy link

sruehl commented Jun 14, 2023

To add on the last section "What did you see instead":

$ go test -v -coverprofile=target/coverage.out ./... > build.log
github.com/apache/plc4x/plc4go/protocols/cbus/readwrite/model: C:\Users\cdutz\.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64\cover.exe: fork/exec C:\Users\cdutz\.mvnGoLang\go1.20.5.windows-amd64\pkg\tool\windows_amd64\cover.exe: Der Dateiname oder die Erweiterung ist zu lang.

@chrisdutz
Copy link
Author

So let me explain what my colleague wanted to provide you with ;-)

So right now whenever Maven detects that it's running on a windows system, we now simply replace the flag: "-coverprofile=target/coverage.out" with a second "-v" (the tool doesn't like empty flags therefore we're just using a double "-v").

@rsc rsc changed the title affected/package: Test cmd/go: test -coverprofile "path too long" error on Windows Jun 14, 2023
@thanm thanm self-assigned this Jun 14, 2023
@thanm
Copy link
Contributor

thanm commented Jun 14, 2023

Thanks for the report, I'll take a look.

@thanm
Copy link
Contributor

thanm commented Jun 14, 2023

A request: if you could please run one of the failing commands with "-x -work" flags in addition and post the output, that would be helpful for me so as to determine which path it is that is over the limit. E.g. output of

go test -x -work -v -coverprofile=target/coverage.out ./...

Thanks.

@thanm thanm added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 14, 2023
@chrisdutz
Copy link
Author

Hope this helps (a bit large)

build.log

@thanm thanm removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 14, 2023
@thanm
Copy link
Contributor

thanm commented Jun 14, 2023

Thanks, yes, that is helpful. It looks as though the issue is with total command line length, not with the length of any specific file being passed to the cover tool. I'll see about crafting a fix.

@chrisdutz
Copy link
Author

I have seen something similar with other tools ... there the length of the command being executed was too long ... they resolved the issue with dynamically creating some sort of batch script, that then is simply called (Not pretty, but it worked)

@thanm
Copy link
Contributor

thanm commented Jun 15, 2023

We have machinery already to handle this for the compiler and the assembler, I just need to update the cover tool to use the same facilities. Will send a CL later today.

@chrisdutz
Copy link
Author

Oh wow ... great :-) Thank you so much :-)

@gopherbot
Copy link

Change https://go.dev/cl/503735 mentions this issue: cmd/{go,cover}: enable response file args for cmd/cover

bradfitz pushed a commit to tailscale/go that referenced this issue Jul 15, 2023
Change the cover command to accept arguments via response files, using
the same mechanism employed for the compiler and the assembler. This
is needed now that the cover tool accepts a list of all source files
in a package, as opposed to just a single source file, and as a result
can run into system-dependent command line length limits.

Fixes golang#60785.

Change-Id: I67dbc96ad9fc5c6f43d5c1e4e903e4b8589b154f
Reviewed-on: https://go-review.googlesource.com/c/go/+/503735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants