Azure / azure-cli

Azure Command-Line Interface
MIT License
3.98k stars 2.95k forks source link

az bicep commands fail with subprocess.CalledProcessError #29962

Open timovirt opened 2 hours ago

timovirt commented 2 hours ago

Describe the bug

az bicep commands on macOS (M1 pro) fail silently. With --debug flag they hint that subprocess.CalledProcessError: Command '['/Users/me/.azure/bin/bicep', '--version']' died with <Signals.SIGKILL: 9>.

Related command

az bicep build -f main.bicep --outdir resources

Errors

Without --debug there's no output, but exit code of the process is 1

Issue script & Debug output

cli.knack.cli: Command arguments: ['bicep', 'build', '-f', 'main.bicep', '--outdir', 'resources', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x100833560>, <function OutputProducer.on_global_arguments at 0x100b94a40>, <function CLIQuery.on_global_arguments at 0x100bb6520>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'bicep': ['azure.cli.command_modules.resource'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: resource 0.093 51 231 cli.azure.cli.core: Total (1) 0.093 51 231 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: Total (0) 0.000 0 0 cli.azure.cli.core: Loaded 51 groups, 231 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : bicep build cli.azure.cli.core: Command table: bicep build cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x101e0a3e0>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/me/.azure/commands/2024-09-23.16-33-00.bicep_build.80293.log'. az_command_data_logger: command args: bicep build -f {} --outdir {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x101e63560>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x101e63600>, <function register_cache_arguments..add_cache_arguments at 0x101e63740>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x101e637e0>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x100b94ae0>, <function CLIQuery.handle_query_parameter at 0x100bb65c0>, <function register_ids_argument..parse_ids_arguments at 0x101e636a0>] cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. cli.azure.cli.command_modules.resource._bicep: Bicep CLI installation path: /Users/me/.azure/bin/bicep cli.azure.cli.command_modules.resource._bicep: Bicep CLI installed: True. cli.azure.cli.core.azclierror: Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/_bicep.py", line 334, in _run_command process.check_returncode() File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 502, in check_returncode raise CalledProcessError(self.returncode, self.args, self.stdout, subprocess.CalledProcessError: Command '['/Users/me/.azure/bin/bicep', '--version']' died with <Signals.SIGKILL: 9>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 666, in execute raise ex File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 733, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 336, in call return self.handler(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/custom.py", line 4671, in build_bicep_file output = run_bicep_command(cmd.cli_ctx, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/_bicep.py", line 94, in run_bicep_command installed_version = _get_bicep_installed_version(installation_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/_bicep.py", line 275, in _get_bicep_installed_version installed_version_output = _run_command(bicep_executable_path, ["--version"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.64.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/_bicep.py", line 350, in _run_command raise UnclassifiedUserFault(error_msg) azure.cli.core.azclierror.UnclassifiedUserFault

cli.azure.cli.core.azclierror: az_command_data_logger: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x101e0a660>] az_command_data_logger: exit code: 1 cli.main: Command ran in 0.462 seconds (init: 0.193, invoke: 0.269)

Expected behavior

main.bicep is converted to main.json file.

Environment Summary

{ "azure-cli": "2.64.0", "azure-cli-core": "2.64.0", "azure-cli-telemetry": "1.1.0", "extensions": { "aks-preview": "5.0.0b1", "interactive": "0.5.3", "k8s-extension": "1.6.1", "log-analytics": "0.2.2", "portal": "0.1.3", "rdbms-connect": "1.0.6" } }

Additional context

Running on Apple M1 Pro, Sonoma 14.4.1

I tried also

brew update && brew install python@3.10 && brew upgrade python@3.10
brew link --overwrite python@3.10

but it didn't change the 3.11 to 3.10.

yonzhan commented 2 hours ago

Thank you for opening this issue, we will look into it.