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

[Issue] azd pipeline config fails when gh.exe in path including a space #3199

Closed
paulsavides opened this issue Jan 15, 2024 · 0 comments · Fixed by #3337
Closed

[Issue] azd pipeline config fails when gh.exe in path including a space #3199

paulsavides opened this issue Jan 15, 2024 · 0 comments · Fixed by #3337
Assignees
Labels
bug Something isn't working core customer-reported identify a customer issue pipelines question
Milestone

Comments

@paulsavides
Copy link

Output from azd version
Run azd version and copy and paste the output here:

PS C:\Users\Paul Savides\src\local\AspireSample> azd version
azd version 1.5.1 (commit 3856d1e98281683b8d112e222c0a7c7b3e148e96)

Describe the bug

I am running through the .net aspire tutorial and got to the step where I am running azd pipeline config.
See tutorial here: https://learn.microsoft.com/en-us/dotnet/aspire/deployment/azure/aca-deployment-github-actions?tabs=windows%2Cvisual-studio

It eventually fails with the following error.

ERROR: failed setting AZD_INITIAL_ENVIRONMENT_CONFIG secret: failed running gh secret set: exit code: 1, stdout: , stderr: 'C:\Users\Paul' is not recognized as an internal or external command,
operable program or batch file.

Note that my home directory is "C:\Users\Paul Savides", note the space.

To Reproduce
Copy gh.exe to a path with a space in it, then run `azd pipeline config with the aspire sample starter template.

For example:

New-Item -Type Directory "C:\look at these spaces"
Copy-Item $HOME\.azd\bin\gh.exe "C:\look at these spaces"
$env:AZD_GH_CLI_TOOL_PATH="C:\look at these spaces\gh.exe"
azd pipeline config

Output =

ERROR: failed setting AZD_INITIAL_ENVIRONMENT_CONFIG secret: failed running gh secret set: exit code: 1, stdout: , stderr: 'C:\look' is not recognized as an internal or external command,
operable program or batch file.

Expected behavior
Github secret should be pushed successfully. If I copy the gh.exe to a path without spaces and use AZD_GH_CLI_TOOL_PATH to override, it does succeed.

Environment
win 11 22621.3007

Additional context
I added some debug logs and printed out the actual go cmd struct content just to see what was actually failing and it was this

ActualCommand={
  Path:C:\WINDOWS\System32\cmd.exe
  Args:[C:\WINDOWS\System32\cmd.exe /c C:\Users\Paul Savides\.azd\bin\gh.exe -R shiftyhosting/AspireSample secret set AZD_INITIAL_ENVIRONMENT_CONFIG --body {"services":{"app":{"config":{"exposedServices":["webfrontend"]}}}}] Env:[] Dir: Stdin: Stdout: Stderr: ExtraFiles:[] SysProcAttr:<nil> Process:<nil> ProcessState:<nil> ctx:<nil> Err:<nil> Cancel:<nil> WaitDelay:0s childIOFiles:[] parentIOPipes:[] goroutine:[] goroutineErr:<nil> ctxResult:<nil> createdByStack:[] lookPathErr:<nil>
}

I believe the part which is causing the issues is the quotes in the json in the command.

You can have a simpler reproduction of the issue if you run direct against cmd and add a quote to a random argument.

For example --

C:\WINDOWS\System32\cmd.exe /c "C:\look at these spaces\gh.exe" auth status --hostname "github.com"
'C:\look' is not recognized as an internal or external command,
operable program or batch file.

To fix, I need to quote the entire command

C:\WINDOWS\System32\cmd.exe /c ""C:\look at these spaces\gh.exe" auth status --hostname "github.com""
github.com
  ✓ Logged in to github.com as paulsavides
... rest of output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core customer-reported identify a customer issue pipelines question
Projects
None yet
3 participants