I'm on a new MacBook Pro M3 and installed Azure CLI using Homebrew as follows:
brew install azure-cli
brew update && brew install python@3.11 && brew upgrade python@3.11
brew link --overwrite python@3.11
When I run az bicep --help
it works fine
When I run az bicep version
or any other command like az bicep upgrade
I get this:
The command failed with an unexpected error. Here is the traceback:
[Errno 8] Exec format error: '/Users/leejohnson/.azure/bin/bicep'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.61.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.61.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.61.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.61.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.61.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.61.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.61.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/custom.py", line 4810, in show_bicep_cli_version
print(run_bicep_command(cmd.cli_ctx, ["--version"], auto_install=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.61.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.61.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.61.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/resource/_bicep.py", line 327, in _run_command
process = subprocess.run(
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/Users/leejohnson/.azure/bin/bicep'
Azure CLI Bicep throwing error on MacBook M3
The error you encountered is due to an issue with the Bicep
executable file that the Azure CLI
is trying to run. Specifically, the error message Exec format erro
r indicates that the file format of the Bicep executable is not compatible with your Mac system architecture.
To resolve this issue, you can try uninstalling and reinstalling the Azure CLI
using the below commands.
brew uninstall azure-cli
rm -rf ~/.azure/bin/bicep
brew update && brew install azure-cli
Reference: Install with Homebrew