air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
18.06k stars 811 forks source link

Air not running properly on windows 11 64bit #659

Open minolmal opened 3 weeks ago

minolmal commented 3 weeks ago

I have tried several suggestions in issues, (both open and closed) still couldn't get Air to properly run the binary. I've run with -d in case it helps. Screenshot 2024-10-10 060728

This is the default config I get from air init. Screenshot 2024-10-10 060748

as you can see here, binary works fine when I run it manually. Screenshot 2024-10-10 062026

I'm not quite sure if it's powershell or Win11, but you can use normal "/" in commands and it works fine. (even in cmd) Screenshot 2024-10-10 062151

(I'm running PowerShell 7.4.5 and Windows 11 Home 22H2 22621.4317)

LuanZwang commented 3 weeks ago

Having the same issue.

image

minolmal commented 3 weeks ago

I've tested the commands in toml. they work fine as well. Screenshot 2024-10-10 063858

I'm new to Go. but I think issue should be somewhere around final paths parsed to "runner".

omarattia3143 commented 3 weeks ago

I have the same issue which is has weird path to bin file -> \'\"main.exe\"' this looks like a bug, but you can avoid this till there is a fix by specifying an absolute path in the toml file -> [build] -> full_bin =""

minolmal commented 3 weeks ago

I have the same issue which is has weird path to bin file -> '\"main.exe\"' this looks like a bug, but you can avoid this till there is a fix by specifying an absolute path in the toml file -> [build] -> full_bin =""

I set full_bin = "<absolute_path>\\tmp\\main.exe" and it worked flawlessly.

LuanZwang commented 3 weeks ago

I have the same issue which is has weird path to bin file -> '\"main.exe\"' this looks like a bug, but you can avoid this till there is a fix by specifying an absolute path in the toml file -> [build] -> full_bin =""

Worked perfectly after it. Thank you!

f-llewellyn commented 3 weeks ago

I have the same issue which is has weird path to bin file -> '"main.exe"' this looks like a bug, but you can avoid this till there is a fix by specifying an absolute path in the toml file -> [build] -> full_bin =""

I set full_bin = "<absolute_path>\\tmp\\main.exe" and it worked flawlessly.

This resolved my issue as well

LuanZwang commented 3 weeks ago

@minolmal, could you close the issue?

omarattia3143 commented 3 weeks ago

@minolmal, could you close the issue?

no this was a temp solution, this needs to be fixed

LuanZwang commented 3 weeks ago

@minolmal, could you close the issue?

no this was a temp solution, this needs to be fixed

yeah, you're right.

omarattia3143 commented 3 weeks ago

I found the issue in this line of code in runner/config.go: c.Build.Bin = fmt.Sprintf("%q", c.Build.Bin) https://github.com/air-verse/air/blame/df13da5c21362c64f16d455feb28d189d9c9f8fd/runner/config.go#L333 related to #646 when the line removed it is working as expected

JasonGoemaat commented 3 weeks ago

Just a comment here as I'm experiencing this on windows 10 also. Not sure what whitespace has to do with this issue but it's mentioned in a pull request dealing with whitespace. The problem seems to be that the full path to the exe is being encoded and escaped as a json string would be. It seems to be returning the same error that would be returned by a command prompt like this:

C:\Users\jason>c:\hello.exe
'c:\hello.exe' is not recognized as an internal or external command,
operable program or batch file.

But the air command includes surrounding double quotes escaped with backslashes and backslashes escaping the other backslashes exactly like this:

C:\Users\jason>\"c:\\hello.exe\"
'\"c:\\hello.exe\"' is not recognized as an internal or external command,
operable program or batch file.

Ah, I see now. That merged PR is mentioned because it is the one that introduced the bug, probably by these lines:

return fmt.Sprintf("%q", filepath.Join(c.Root, bin))
moboqe commented 2 weeks ago

I found the issue in this line of code in runner/config.go: c.Build.Bin = fmt.Sprintf("%q", c.Build.Bin) https://github.com/air-verse/air/blame/df13da5c21362c64f16d455feb28d189d9c9f8fd/runner/config.go#L333 related to #646 when the line removed it is working as expected

Yeah, that is the source of the issue in my win10 as well

before after

cosmtrek commented 2 weeks ago

I'll revert the commit and release a new version. Then fix and fully test the broken pr.

minolmal commented 2 weeks ago

Air v1.61.1 with default config seems to be working fine.

@cosmtrek Thank you for the quick response. I think this commit should correct several issues in the issues log. should I close this one?