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 - The system cannot find the file specified #11735

Closed
Trovalo opened this issue Aug 29, 2022 · 12 comments
Closed

Building on Windows - The system cannot find the file specified #11735

Trovalo opened this issue Aug 29, 2022 · 12 comments
Labels
bug unexpected problem or unintended behavior platform/windows

Comments

@Trovalo
Copy link
Collaborator

Trovalo commented Aug 29, 2022

The latest Telegraf code cannot be built on Windows you get the following error:

env -u GOOS -u GOARCH -u GOARM -- go build -o ./tools/custom_builder/custom_builder.exe ./tools/custom_builder
process_begin: CreateProcess(NULL, env -u GOOS -u GOARCH -u GOARM -- go build -o ./tools/custom_builder/custom_builder.exe ./tools/custom_builder, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:117: build_tools] Error 2

Note: under "support" as I couldn't fill the mandatory field for an issue

@Trovalo Trovalo added the support Telegraf questions, may be directed to community site or slack label Aug 29, 2022
@telegraf-tiger
Copy link
Contributor

Hello! I recommend posting this question in our Community Slack or Community Page, we have a lot of talented community members there who could help answer your question more quickly. You can also learn more about Telegraf by enrolling at InfluxDB University for free!

Heads up, this issue will be automatically closed after 7 days of inactivity. Thank you!

@spaghettidba
Copy link
Contributor

It's line 47 in the makefile:

HOSTGO := env -u GOOS -u GOARCH -u GOARM -- go

"env" is not a valid windows command.
Changing to this will fix it:

HOSTGO := go

@powersj
Copy link
Contributor

powersj commented Aug 29, 2022

Hey,

Are you both using powershell to run the Makefile?

We had a previous issue where we tried to get powershell to work with Make, we ultimately decided it would be much easier to support the "Bash for Git" terminal on Windows. Trying to add additional if statements for Makefile in various places to handle the oddities of PowerShell became less and less appealing.

"env" is not a valid windows command.

Right, however we need to unset these values when doing cross-builds.

@spaghettidba
Copy link
Contributor

Thanks for chiming in!
It's the same under powershell or cmd.

Right, however we need to unset these values when doing cross-builds.

In windows the command to unset an environment variable is SET with an empty value:

SET GOOS=
SET GOARCH=
SET GOARM=

I have no idea how to take different paths in the makefile depending on the os

@spaghettidba
Copy link
Contributor

spaghettidba commented Aug 30, 2022

"Bash for Git"

Sorry, I didn't catch this bit before. Bash for git is a Martian object in Windows. Supporting software in Windows through Bash for Git is the equivalent of supporting software in linux through Wine.
Powershell does have some oddities, but the build is still 100% working without those env commands. It does not seem overly complex to add os-dependent code just for one line.

@powersj
Copy link
Contributor

powersj commented Aug 30, 2022

Bash for git is a Martian object in Windows.

As are Makefiles/make, git, and go; all of which are dependencies required to build Telegraf using the Makefile. I treat using "bash" to use the Makefile as another dependency. I am not sure how else you would install git, but as a part of the install process getting bash for git is readily available.

but the build is still 100% working without those env commands

The build yes, but if you look at the bug I linked to the problems do not end there. I am interested in the Makefile to just work in Windows and would be happy to see a PR to get it working, but at the same time, I'm not thrilled to support or maintain the additional complexity. I would also mention that our Windows builds are built using the Makefile in bash as well. It keeps things consistent for our build tooling across all three platforms. If we start adding PowerShell/Windows-specific options we have to ensure that Windows works with both PowerShell and/or bash.

It does not seem overly complex to add os-dependent code just for one line.

Unfortunately, the problems do not end there. There are other commands mentioned in the bug above that also do not work. If we are going to support the Makefile in a PowerShell environment, then I believe we need to ensure we can depend on other subcommands as well. Otherwise, this is an endless trickle of issues.

@spaghettidba
Copy link
Contributor

I see your point. My custom build invokes make from a powershell script, so I guess I will have to rewrite it in bash. Bummer.

@reimda
Copy link
Contributor

reimda commented Aug 30, 2022

Let's make sure it's documented that windows builds require git bash so future users don't run into this.

@reimda
Copy link
Contributor

reimda commented Aug 30, 2022

Looks like it's already in the main readme:

https://github.com/influxdata/telegraf#build-from-source

@spaghettidba
Copy link
Contributor

The easiest way is to fail the build (with a meaningful message) if not running from bash.

@reimda reimda added bug unexpected problem or unintended behavior platform/windows and removed support Telegraf questions, may be directed to community site or slack labels Aug 30, 2022
@reimda
Copy link
Contributor

reimda commented Aug 30, 2022

The easiest way is to fail the build (with a meaningful message) if not running from bash.

I agree, a helpful message would be best.

I don't develop on windows much. I don't know of a good cross-platform way to check for this condition. We could run a windows command that will cause an error on linux, or run a linux command that will cause an error on windows.

I suppose we could check go env GOHOSTOS since that is available on both. Do you have any other suggestions?

@Trovalo
Copy link
Collaborator Author

Trovalo commented Aug 31, 2022

I'm not that knowledgeable in makefiles, is it possible to catch and exception and return a custom error message?
if yes, doing as you said just (running go env) will suffice to understand whether the console is compatible or not

The other option I see is to check if Windows is being used (easy by checking env vars) and what's the current console (not easy... I found nothing about how to do that) then throw a custom error...

I think the first option is the best as there might be other linux-like consoles that work on windows...

@Trovalo Trovalo closed this as completed Jan 9, 2023
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

No branches or pull requests

4 participants