WinError 193 When running Bicep commands on Az CLI
This is autogenerated. Please review and update as needed.
Describe the bug
Issue when trying to run bicep related Az CLI commands
Command Name
az bicep version OR
az deployment group create (with any file - those that previously worked and have not changed) OR
az bicep build (with any file - those that previously worked and have not changed)
Errors:
The command failed with an unexpected error. Here is the traceback:
[WinError 193] %1 is not a valid Win32 application
Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 3568, in show_bicep_cli_version
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 69, in run_bicep_command
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 181, in _get_bicep_installed_version
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 215, in _run_command
File "subprocess.py", line 493, in run
File "subprocess.py", line 858, in __init__
File "subprocess.py", line 1311, in _execute_child
OSError: [WinError 193] %1 is not a valid Win32 application
To Reproduce:
Steps to reproduce the behaviour. Note that argument values have been redacted, as they may contain sensitive information.
Start windows terminal (powershell)/terminal session inside of VS code and run command az bicep version
Expected Behaviour
Current running bicep version should be shown
Environment Summary
Windows-10-10.0.22000-SP0
Python 3.8.9
Installer: MSI
azure-cli 2.29.0 *
Additional Context
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.
Issue Details
This is autogenerated. Please review and update as needed.
Describe the bug
Issue when trying to run bicep related Az CLI commands
Command Name
az bicep version OR
az deployment group create (with any file - those that previously worked and have not changed) OR
az bicep build (with any file - those that previously worked and have not changed)
Errors:
The command failed with an unexpected error. Here is the traceback:
[WinError 193] %1 is not a valid Win32 application
Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 3568, in show_bicep_cli_version
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 69, in run_bicep_command
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 181, in _get_bicep_installed_version
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 215, in _run_command
File "subprocess.py", line 493, in run
File "subprocess.py", line 858, in __init__
File "subprocess.py", line 1311, in _execute_child
OSError: [WinError 193] %1 is not a valid Win32 application
To Reproduce:
Steps to reproduce the behaviour. Note that argument values have been redacted, as they may contain sensitive information.
Start windows terminal (powershell)/terminal session inside of VS code and run command az bicep version
Expected Behaviour
Current running bicep version should be shown
Environment Summary
Windows-10-10.0.22000-SP0
Python 3.8.9
Installer: MSI
azure-cli 2.29.0 *
Additional Context
| Author: | dapontin |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
route to service team
@dapontin Could you check if invoking directly the Bicep executable installed by Azure CLI works? For example:
%USERPROFILE%\.azure\bin\bicep.exe --version
Here is the output:
PS C:\Users\dapontin> C:\Users\dapontin\.azure\bin\bicep.exe --version
Program 'bicep.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1
char:1
+ C:\Users\dapontin\.azure\bin\bicep.exe --version
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ C:\Users\dapontin\.azure\bin\bicep.exe --version
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
It seems bicep.exe is broken somehow. Can you try az bicep uninstall and az bicep install to install it again?
I can assure you that I successfully uninstall and re-installed bicep before I raised this issue, and the error was still present. However, I completed your instructions to run az bicep uninstall and az bicep install in the interest of clarity and now the issue is no longer present! Here is the result:
PS C:\Users\dapontin> az bicep version
Bicep CLI version 0.4.1008 (223b8d227a)
Thanks for your help - apologies that it was a simple fix!
No worries. Glad it worked!
have you initially installed bicep by winget? I suspect that az cli searches for bicep in a specific position, ignoring the Path env variable.