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

make: fails on Windows environments #11609

Closed
powersj opened this issue Aug 3, 2022 · 12 comments
Closed

make: fails on Windows environments #11609

powersj opened this issue Aug 3, 2022 · 12 comments
Labels
bug unexpected problem or unintended behavior

Comments

@powersj
Copy link
Contributor

powersj commented Aug 3, 2022

Relevant telegraf.conf

n/a

Logs from Telegraf

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


---
PS C:\Users\powersj\telegraf> make
go mod download -x
go build -o ./tools/license_checker/license_checker ./tools/license_checker
go build -o ./tools/readme_config_includer/generator ./tools/readme_config_includer/generator.go
go generate -run="readme_config_includer/generator$" ./plugins/inputs/...
plugins\inputs\activemq\activemq.go:1: running "../../../tools/readme_config_includer/generator": exec: "C:\\Users\\powersj\\telegraf\\tools\\readme_config_includer\\generator": file does not exist
plugins\inputs\aerospike\aerospike.go:1: running "../../../tools/readme_config_includer/generator": exec: "C:\\Users\\powersj\\telegraf\\tools\\readme_config_includer\\generator": file does not exist
plugins\inputs\aliyuncms\aliyuncms.go:1: running "../../../tools/readme_config_includer/generator": exec: "C:\\Users\\powersj\\telegraf\\tools\\readme_config_includer\\generator": file does not exist


---
PS C:\Users\powersj\telegraf> make clean
rm -f telegraf
process_begin: CreateProcess(NULL, rm -f telegraf, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:227: clean] Error 2

System info

Windows 10/11

Docker

n/a

Steps to reproduce

  1. clone the repo
  2. run make or make build-tools or make clean

Expected behavior

Telegraf builds successfully, make commands works

Actual behavior

The above failure

Additional info

It appears that our makefile, now that we are building additional tools and dealing with other paths fails. Some issues I have seen:

  1. The HOSTGO variable tries to unset the GOOS, GOARCH, and GOARM variables. In Windows env is not a thing.
  2. Even after building the build_tools, the build fails due to being unable to find the readme_config_includer binary
  3. The make clean command fails if any of the files are not available, unlike on linux/macos.
@powersj powersj added the bug unexpected problem or unintended behavior label Aug 3, 2022
@powersj powersj changed the title make: fails on Windows enviornments make: fails on Windows environments Aug 3, 2022
@sspaink
Copy link
Contributor

sspaink commented Aug 3, 2022

The HOSTGO variable tries to unset the GOOS, GOARCH, and GOARM variables. In Windows env is not a thing.

I have no idea what the purpose of this is, looks like it got added in a fairly old commit: #7759 I think we might be able to just delete $HOSTGO it doesn't seem to be used anywhere but the build tools.

@sspaink
Copy link
Contributor

sspaink commented Aug 3, 2022

···························································································································· 
❯ make clean
rm -f telegraf
rm -f telegraf.exe
rm -rf build
rm -rf tools/readme_config_includer/generator
rm -rf tools/readme_config_includer/generator.exe
rm -rf tools/package_lxd_test/package_lxd_test
rm -rf tools/package_lxd_test/package_lxd_test.exe
rm -rf tools/license_checker/license_checker
rm -rf tools/license_checker/license_checker.exe

····························································································································
❯ make clean
rm -f telegraf
rm -f telegraf.exe
rm -rf build
rm -rf tools/readme_config_includer/generator
rm -rf tools/readme_config_includer/generator.exe
rm -rf tools/package_lxd_test/package_lxd_test
rm -rf tools/package_lxd_test/package_lxd_test.exe
rm -rf tools/license_checker/license_checker
rm -rf tools/license_checker/license_checker.exe

I am able to run make clean multiple times without failure, maybe there is something different in my environment?

@powersj
Copy link
Contributor Author

powersj commented Aug 3, 2022

I have no idea what the purpose of this is, looks like it got added in a fairly old commit: #7759 I think we might be able to just delete $HOSTGO it doesn't seem to be used anywhere but the build tools.

It got added for cross-builds. For example if I am on Linux and run GOOS=windows make that GOOS will pass into the make build_tools command which will build a windows version of the licence checker, readme linter, etc. Then because make will execute the docs and then embed_readme_% targets it will try to run a windows executable, failing the build.

One solution is to remove the docs target from the default make command, but that might defeat the purpose of it?

@powersj
Copy link
Contributor Author

powersj commented Aug 3, 2022

I am able to run make clean multiple times without failure, maybe there is something different in my environment?

On Linux this is fine, because of the force flag. However, are you trying on Windows? Because on windows the -f flag is not a thing.

PS C:\Users\powersj> rm -f test
Remove-Item : Parameter cannot be processed because the parameter name 'f' is ambiguous.
Possible matches include: -Filter -Force.
At line:1 char:4
+ rm -f test
+    ~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-Item], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.RemoveItemCo
   mmand
PS C:\Users\powersj> rm -Force test
rm : Cannot find path 'C:\Users\powersj\test' because it does not exist.
At line:1 char:1
+ rm -Force test
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\powersj\test:String) [Remove-Item],
    ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

@sspaink
Copy link
Contributor

sspaink commented Aug 3, 2022

Ah I see, I was running on Windows in a bash terminal I wasn't using Powershell. Adding support for Powershell should be possible, seems like this is a possible solution: https://stackoverflow.com/questions/63157509/rm-f-equivalent-for-powershell-that-ignore-nonexistent-files

@powersj
Copy link
Contributor Author

powersj commented Aug 3, 2022

Windows in a bash terminal

aaaah! ok that makes sense and I was trying to figure out why we are not seeing these issues in CI and realized we use bash there as well.

How hard is it to install the bash terminal in Windows? I have seen a doc that requires installing WSL and I think that is a bit too much to ask of users.

@sspaink
Copy link
Contributor

sspaink commented Aug 3, 2022

Pretty easy when you use the bash emulation that comes with Git: https://gitforwindows.org/ which is what I am using. Using WSL is definitely more involved but also possible.

@powersj
Copy link
Contributor Author

powersj commented Aug 3, 2022

Ah it uses MinGW.

I am wondering if stating that our Makefile requires MinGW on windows is a low bar, to avoid making even more custom changes, especially if a user is already going to the effort to install make on windows.

Thoughts?

@sspaink
Copy link
Contributor

sspaink commented Aug 3, 2022

I would prefer not adding support for Powershell if we can avoid it, lets just update the documentation saying it requires MinGW. I can do it in #11608

@powersj
Copy link
Contributor Author

powersj commented Aug 3, 2022

Agreed - in the docs if you can show how to install it and start up bash I think that would be acceptable.

Thanks!

@barts2108
Copy link

Acceptable: This issue was started after a post of me over here
https://community.influxdata.com/t/build-telegraf-in-windows-fails/25988

Now I was able to use git-bash to compile on windows for both windows and linux. No cmd.exe or powershell required.

@powersj
Copy link
Contributor Author

powersj commented Aug 4, 2022

Thanks for the response.

I think the PR from last night cleans these up and gets a working makefile under windows again with bash. As such I am going to close this issue.

Thanks again!

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
Projects
None yet
Development

No branches or pull requests

3 participants