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

Cmd parsing error on Windows #707

Open
n1vk opened this issue Dec 3, 2024 · 1 comment
Open

Cmd parsing error on Windows #707

n1vk opened this issue Dec 3, 2024 · 1 comment

Comments

@n1vk
Copy link

n1vk commented Dec 3, 2024

While using air to run delve, I edit cmd in .air.toml to have build flags.

cmd = "go build -gcflags='all=-N -l' -o ./tmp/main.exe"

However this would produce error:

invalid value "'all=-N" for flag -gcflags: parameter may not start with quote character '

After a bit looking into the codes, I found out it was because of using cmd /c. In runner/util_windows.go:24, we have

c := exec.Command("cmd", "/c", cmd)

You can run this on Windows and reproduce the bug:

cmd /c "go build -gcflags='all=-N -l' -o ./tmp/main.exe"

Maybe replacing cmd /c with powershell?

@n1vk
Copy link
Author

n1vk commented Dec 3, 2024

Another issue is that air falls back to default config silently.

While I was looking for solutions, I changed -gcflags to use ", \' and \". It might be obvious that using " will cause parsing failure, but only when calling air -c .air.toml would produce the error.

Calling air should have explicit warning of not using local .air.toml. (Like #709)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant