Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

Seems like there is an issue i'm getting this error while deploying [WinError 193] %1 is not a valid Win32 application #18915

Open gopisettyr opened 3 years ago

gopisettyr commented 3 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az bicep upgrade

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 3418, in upgrade_bicep_cli
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 93, in ensure_bicep_installation
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 171, 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 205, 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 behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.26.1

Additional Context

ghost commented 3 years ago

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 **Command Name** `az bicep upgrade` **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 3418, in upgrade_bicep_cli File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 93, in ensure_bicep_installation File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 171, 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 205, 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 behavior. Note that argument values have been redacted, as they may contain sensitive information. - _Put any pre-requisite steps here..._ - `az bicep upgrade` ## Expected Behavior ## Environment Summary ``` Windows-10-10.0.19041-SP0 Python 3.8.9 Installer: MSI azure-cli 2.26.1 ``` ## Additional Context
Author: gopisettyr
Assignees: -
Labels: `ARM`, `Service Attention`
Milestone: -
yonzhan commented 3 years ago

route to service team

snaheth commented 3 years ago

Hi @gopisettyr, thanks for bringing this up.

When you check your PATH variable ($Env:PATH in PowerShell, for example) - do you see a path listed that contains a python executable (something like D:\Python38\)?

danponting commented 2 years ago

Has their been any progress on this? I am receiving the same error when running any bicep commands on the Az CLI such as

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

I have tried uninstalling & re-installing both Az CLI and bicep but still receive the same issue

shenglol commented 2 years ago

Hi @gopisettyr, could you confirm if you are still getting this error? Did you try running the same command in the latest version of Azure CLI?

sosoriov commented 2 years ago

I'm having the same issue using the latest version

{ "azure-cli": "2.30.0", "azure-cli-core": "2.30.0", "azure-cli-telemetry": "1.0.6", "extensions": {} }

AGregersen commented 2 years ago

We get it when using az bicep publish --file --target "br:.azurecr.io/bicep/modules/:0.1.3r" through Octopus Deploy, but not if I run it directly. { "azure-cli": "2.34.1", "azure-cli-core": "2.34.1", "azure-cli-telemetry": "1.0.6", "extensions": {} }

Bicep CLI version 0.4.1318 (ee0d808f35)

Update: After further investigation our problem was caused by az bicep is a per-user installation - so the error we got was basically a very bad way of saying bicep was not installed in that service accounts context, instead of saying "you are trying to run bicep but it's not installed"

chaoscreater commented 2 years ago

Hi @gopisettyr, thanks for bringing this up.

When you check your PATH variable ($Env:PATH in PowerShell, for example) - do you see a path listed that contains a python executable (something like D:\Python38\)?

Yes. I have Python 3.9.5 and 2.7.17 installed already and added to PATH, prior to installing BICEP. I can see there're Python related files under 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2', but not sure if I should add that to PATH because that would probably conflict with my other Python paths?

UPDATE:

NVM, issue is unrelated to existing Python installs. Just had to follow this instruction here: https://github.com/Azure/bicep/issues/2364#issuecomment-825049091