air icon indicating copy to clipboard operation
air copied to clipboard

Adding flags to compiled binary adds .exe to the end

Open jherman opened this issue 4 years ago • 3 comments

In a Windows environment, using the following in the toml file:

bin = "tmp\\main.exe --read-envar-file=envar.yaml"

results in error because air is adding .exe at the very end.

I don't believe it should be doing this. It should be the responsibility of the user to make sure their bin is proper.

jherman avatar Jul 07 '21 17:07 jherman

You should probably use full_bin in the toml for that use case. Abominably, full_bin is also added .exe.

There is a workaround:

full_bin = "tmp\\main.exe --read-envar-file=envar.yaml\nrem "

This string is passed to the command cmd.exe /C , and cmd does not execute the string after a newline (the string after newline which is rem .exe is a comment line, so it has no effect if it is executed).

makiuchi-d avatar Jul 17 '21 10:07 makiuchi-d

hotbuild.ffactory.org

wandercn avatar Jul 23 '21 02:07 wandercn

I was wondering why I couldn't get air to work properly on my Windows PC.

@makiuchi-d Thanks, that's a decent workaround for now. Had to change mine from full_bin = "./tmp/main serve" to full_bin = "./tmp/main serve\nrem "

Seems like it's adding .exe to the end of full_bin for windows here: https://github.com/cosmtrek/air/blob/4f76c39874dca4266f2f05dff613e8bde4253e5a/runner/util.go#L220

Kind of annoying since I don't even need .exe at all.

Torrunt avatar Aug 12 '21 07:08 Torrunt