azure-cli: Error "'C:\Program' is not recognized as an internal or external command" when running az role assignment create cmd

Describe the bug Running the 1st bash script in doc Authenticate with Azure Container Registry from Azure Kubernetes Service, last cmd generates error

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Other az-cli cmds work in the same environment so far.

Environment summary Windows 10, git bash in mingw64, alias az=az.cmd

$ az --version
azure-cli                         2.0.62 *

acr                                2.2.4 *
acs                               2.3.21 *
advisor                            2.0.0
ams                                0.4.4 *
appservice                        0.2.17 *
backup                             1.2.3 *
batch                              4.0.0
batchai                            0.4.8
billing                            0.2.1
botservice                        0.1.10
cdn                                0.2.2 *
cloud                              2.1.1
cognitiveservices                  0.2.5
command-modules-nspkg               2.0.2
configure                         2.0.21 *
consumption                        0.4.2
container                         0.3.16
core                              2.0.62 *
cosmosdb                           0.2.9 *
dla                                0.2.5
dls                                0.1.8 *
dms                                0.1.3
eventgrid                          0.2.2 *
eventhubs                          0.3.4
extension                          0.2.5
feedback                           2.2.0 *
find                               0.3.2
hdinsight                          0.3.3
interactive                        0.4.3
iot                                0.3.7 *
iotcentral                         0.1.6
keyvault                          2.2.14
kusto                              0.2.2
lab                                0.1.6 *
maps                               0.3.4
monitor                           0.2.12 *
network                            2.3.6 *
nspkg                              3.0.3
policyinsights                     0.1.2
privatedns                         1.0.0
profile                            2.1.5
rdbms                              0.3.9 *
redis                              0.4.2
relay                              0.1.4
reservations                       0.4.2
resource                          2.1.13 *
role                               2.5.0 *
search                             0.1.1
security                           0.1.1
servicebus                         0.3.4
servicefabric                     0.1.16 *
signalr                            1.0.0
sql                                2.2.1 *
sqlvm                              0.1.1
storage                            2.4.0 *
telemetry                          1.0.2
vm                                2.2.18 *

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 18 (9 by maintainers)

Most upvoted comments

This is a bug in Git Bash itself, irrelevant to Azure CLI.

To reproduce, create a cmd file with spaces in the path, such as D:\path with space\test.cmd:

echo Hello World

Directly invoking this file works:

$ test.cmd

C:\Users\xxx>echo Hello World
Hello World

$ "D:\path with space\test.cmd"

C:\Users\xxx>echo Hello World
Hello World

But it fails when a parameter with space is provided:

$ test.cmd "a b"
'D:\path' is not recognized as an internal or external command,
operable program or batch file.

$ "D:\path with space\test.cmd" "a b"
'D:\path' is not recognized as an internal or external command,
operable program or batch file.

yes