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

Building on Windows with GNU make results in unrunnable binary #11014

Closed
bewing opened this issue Apr 21, 2022 · 2 comments · Fixed by #11015
Closed

Building on Windows with GNU make results in unrunnable binary #11014

bewing opened this issue Apr 21, 2022 · 2 comments · Fixed by #11015
Labels
bug unexpected problem or unintended behavior platform/windows

Comments

@bewing
Copy link
Contributor

bewing commented Apr 21, 2022

Relevant telegraf.conf

[[outputs.file]]
   files = ["stdout"]

Logs from Telegraf

$ ./telegraf.exe --version
Telegraf -9e741ef2 (git: iss11007 9e741ef2)

./telegraf.exe --config C:\Users\bewing\telegraf.conf
panic:  is not in dotted-tri format

goroutine 1 [running]:
github.com/coreos/go-semver/semver.Must(...)
        C:/Users/bewing/go/pkg/mod/github.com/coreos/[email protected]/semver/semver.go:65
github.com/coreos/go-semver/semver.New({0x60736f0, 0xf})
        C:/Users/bewing/go/pkg/mod/github.com/coreos/[email protected]/semver/semver.go:49 +0x45
github.com/influxdata/telegraf/config.NewConfig()
        C:/Users/bewing/Projects/telegraf/config/config.go:121 +0x31c
main.runAgent({0x61cffc0, 0xc000442fc0}, {0x90206d8, 0x0, 0x0}, {0x90206d8, 0x0, 0x0})
        C:/Users/bewing/Projects/telegraf/cmd/telegraf/telegraf.go:210 +0x8b
main.reloadLoop({0x90206d8, 0x0, 0x0}, {0x90206d8, 0x0, 0x0})
        C:/Users/bewing/Projects/telegraf/cmd/telegraf/telegraf.go:158 +0x28a
main.run({0x90206d8, 0x0, 0x0}, {0x90206d8, 0x0, 0x0})
        C:/Users/bewing/Projects/telegraf/cmd/telegraf/telegraf_windows.go:28 +0xcc
main.main()
        C:/Users/bewing/Projects/telegraf/cmd/telegraf/telegraf.go:501 +0xa6a

System info

Telegraf 1.23.0, Windows 11, Powershell 5.1.22000.282, GNU make 3.81

Docker

No response

Steps to reproduce

Compile on Windows via make build

Expected behavior

Working binary

Actual behavior

Binary fails to start due to non-semantic versioning

Additional info

Output from make build:

$ make build
process_begin: CreateProcess(NULL, cat build_version.txt, ...) failed.
go build -ldflags " -X main.commit=9e741ef2 -X main.branch=iss11007 -X main.goos=windows -X main.goarch=amd64 -X main.version=-9e741ef2" ./cmd/telegraf

Having a fallback semantic version of 0.0.0 might work?

@bewing bewing added the bug unexpected problem or unintended behavior label Apr 21, 2022
powersj added a commit to powersj/telegraf that referenced this issue Apr 21, 2022
The makefile runs some shell commands to collect version information
about the build. The changes currently fail on Windows becuase of some
unix only options and commands. This fixes the two specific lines with
commands to allow the build, testing, etc. to work as expected.

Fixes: influxdata#11014
@powersj
Copy link
Contributor

powersj commented Apr 21, 2022

The makefile has these two lines at the very top that are used to read the content of build_version.txt and determine if we are build a specific tag:

next_version :=  $(shell cat build_version.txt)
tag := $(shell git describe --exact-match --tags 2>git_describe_error.tmp; rm -f git_describe_error.tmp)

The shell used on windows by default is sh.exe, where cat does not exist and the -f option for rm is not a thing, that is a unix-only flag. I have put up #11015 to run platform-specific commands for these two to allow the build to correctly set the version.

@mattbaron
Copy link

mattbaron commented Feb 11, 2023

I ran into this problem on macOS Monteray. The issue was with this line in Makefile:

next_version := $(file < build_version.txt)

The file operation requires make version 4.2 or greater. The version of make that came with my Xcode cmdline tools is 3.81.

My fix was to install make via Homebrew and build with gmake

# brew install make
# gmake build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior platform/windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants