Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

OSError: [Errno 8] Exec format error: #27429

Open darren221980 opened 1 year ago

darren221980 commented 1 year ago

Describe the bug

Hi,

So, I've created myself a VM using the Ubuntu 64-bit ARM Server 22.04.3 iso image. I've configured it as a agent to use with Azure Dev Ops. I've installed the azurecli and bicep but when attempting to run az bicep version i get the error detailed below.

Related command

az bicep version

Errors

darren@darren-ubuntu:~$ az bicep version The command failed with an unexpected error. Here is the traceback: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep' Traceback (most recent call last): File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(args, kwargs) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/custom.py", line 4401, in show_bicep_cli_version print(run_bicep_command(cmd.cli_ctx, ["--version"], auto_install=False)) File "/opt/az/lib/python3.10/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/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 267, in _get_bicep_installed_version installed_version_output = _run_command(bicep_executable_path, ["--version"]) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 305, in _run_command process = subprocess.run([rf"{bicep_installation_path}"] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "/opt/az/lib/python3.10/subprocess.py", line 503, in run with Popen(popenargs, **kwargs) as process: File "/opt/az/lib/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/opt/az/lib/python3.10/subprocess.py", line 1847, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep'

Issue script & Debug output

darren@darren-ubuntu:~$ az bicep version --debug cli.knack.cli: Command arguments: ['bicep', 'version', '--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 0xffffbc8113f0>, <function OutputProducer.on_global_arguments at 0xffffbc720310>, <function CLIQuery.on_global_arguments at 0xffffbc529510>] 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.005 51 226 cli.azure.cli.core: Total (1) 0.005 51 226 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, 226 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : bicep version cli.azure.cli.core: Command table: bicep version cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0xffffbb5deef0>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/darren/.azure/commands/2023-09-19.16-06-06.bicep_version.30572.log'. az_command_data_logger: command args: bicep version --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0xffffbb5fba30>] cli.azure.cli.core.profiles._shared: Traceback (most recent call last): File "/opt/az/lib/python3.10/site-packages/azure/cli/core/profiles/_shared.py", line 655, in _get_attr op = getattr(op, part) AttributeError: module 'azure.mgmt.resource.resources.v2022_09_01.models' has no attribute 'ExemptionCategory'

cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0xffffbb641870>, <function register_cache_arguments..add_cache_arguments at 0xffffbb641990>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0xffffbc7203a0>, <function CLIQuery.handle_query_parameter at 0xffffbc5295a0>, <function register_ids_argument..parse_ids_arguments at 0xffffbb641900>] 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: /home/darren/.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/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(args, kwargs) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/custom.py", line 4401, in show_bicep_cli_version print(run_bicep_command(cmd.cli_ctx, ["--version"], auto_install=False)) File "/opt/az/lib/python3.10/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/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 267, in _get_bicep_installed_version installed_version_output = _run_command(bicep_executable_path, ["--version"]) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 305, in _run_command process = subprocess.run([rf"{bicep_installation_path}"] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "/opt/az/lib/python3.10/subprocess.py", line 503, in run with Popen(popenargs, **kwargs) as process: File "/opt/az/lib/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/opt/az/lib/python3.10/subprocess.py", line 1847, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep'

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback: az_command_data_logger: The command failed with an unexpected error. Here is the traceback: cli.azure.cli.core.azclierror: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep' Traceback (most recent call last): File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(args, kwargs) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/custom.py", line 4401, in show_bicep_cli_version print(run_bicep_command(cmd.cli_ctx, ["--version"], auto_install=False)) File "/opt/az/lib/python3.10/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/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 267, in _get_bicep_installed_version installed_version_output = _run_command(bicep_executable_path, ["--version"]) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 305, in _run_command process = subprocess.run([rf"{bicep_installation_path}"] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "/opt/az/lib/python3.10/subprocess.py", line 503, in run with Popen(popenargs, kwargs) as process: File "/opt/az/lib/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/opt/az/lib/python3.10/subprocess.py", line 1847, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep' az_command_data_logger: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep' Traceback (most recent call last): File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute raise ex File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job result = cmd_copy(params) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call return self.handler(args, kwargs) File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(command_args) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/custom.py", line 4401, in show_bicep_cli_version print(run_bicep_command(cmd.cli_ctx, ["--version"], auto_install=False)) File "/opt/az/lib/python3.10/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/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 267, in _get_bicep_installed_version installed_version_output = _run_command(bicep_executable_path, ["--version"]) File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py", line 305, in _run_command process = subprocess.run([rf"{bicep_installation_path}"] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "/opt/az/lib/python3.10/subprocess.py", line 503, in run with Popen(popenargs, kwargs) as process: File "/opt/az/lib/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/opt/az/lib/python3.10/subprocess.py", line 1847, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/darren/.azure/bin/bicep' To check existing issues, please visit: https://github.com/Azure/azure-cli/issues cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0xffffbb5df130>] az_command_data_logger: exit code: 1 cli.main: Command ran in 0.199 seconds (init: 0.095, invoke: 0.104) telemetry.main: Begin splitting cli events and extra events, total events: 1 telemetry.client: Accumulated 0 events. Flush the clients. telemetry.main: Finish splitting cli events and extra events, cli events: 1 telemetry.save: Save telemetry record of length 6812 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "/usr/bin/../../opt/az/bin/python3 /opt/az/lib/python3.10/site-packages/azure/cli/telemetry/init.py /home/darren/.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.

Expected behavior

bicep version to be presented.

Environment Summary

azure-cli 2.52.0

core 2.52.0 telemetry 1.1.0

Extensions: ssh 2.0.1

Dependencies: msal 1.24.0b1 azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3' Extensions directory '/home/darren/.azure/cliextensions'

Python (Linux) 3.10.10 (main, Aug 31 2023, 09:17:29) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 year ago

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

azure-client-tools-bot-prd[bot] commented 1 year ago
Hi @darren221980 Find similar issue https://github.com/Azure/azure-cli/issues/18177.
Issue title Failure during 'az bicep upgrade'
Create time 2021-05-21
Comment number 4

Possible solution: The error message in the new issue is similar to the error message in the old issue, which is related to permission denied when accessing the bicep binary. In the old issue, the user had to manually delete the .azure folder and do a fresh install of azure-cli and bicep to solve the issue. Therefore, I suggest trying the same solution for the new issue. Manually delete the .azure folder and do a fresh install of azure-cli and bicep. This should solve the issue.


Please confirm if this resolves your issue.

darren221980 commented 1 year ago

Hi @darren221980 Find similar issue #18177.

Issue title Failure during 'az bicep upgrade' Create time 2021-05-21 Comment number 4 Possible solution: The error message in the new issue is similar to the error message in the old issue, which is related to permission denied when accessing the bicep binary. In the old issue, the user had to manually delete the .azure folder and do a fresh install of azure-cli and bicep to solve the issue. Therefore, I suggest trying the same solution for the new issue. Manually delete the .azure folder and do a fresh install of azure-cli and bicep. This should solve the issue.

Please confirm if this resolves your issue.

Unfortunately this didn't fix it for me. I've tried removing the .azure folder and then done a fresh install of azure-cli and bicep a few times now with the same result.

anthony-c-martin commented 1 year ago

Seems likely related to #27333.

Could you try running the following before executing any bicep commands, to see if this fixes your issue:

az bicep install --target-platform linux-arm64
ferantivero commented 7 months ago

Seems likely related to #27333.

Could you try running the following before executing any bicep commands, to see if this fixes your issue:

az bicep install --target-platform linux-arm64

yes @anthony-c-martin, you were totally right. This helped me to solve the issue. Thanks,