Modules

Feb 01, 2021

Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!

When you are Trying to get Azure functions core tool on my M2 Mac (it's got an Apple M2 Pro chip), An error pops up every time. It's like tool won't work nice with my setup. Basically, it's a no-go, leaving me hanging without the stuff I need. It's all about trying to make this software work on my specific kind of Mac, but it's just not happening. Total bummer, right?

I’m using brew package manager and I have already enabled Rosetta following the instructions given by microsoft. Can anyone help me on this? Really appreciate!

Error

brew install azure-functions-core-tools@4
# if upgrading on a machine that has 2.x or 3.x installed:
brew link --overwrite azure-functions-core-tools@4
azure-functions-core-tools@4 4.0.5390 is already installed but outdated (so it will be upgraded).
Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
    arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.

Why is This Error?

The error message “Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!” indicates an issue with attempting to install software through Homebrew on an Apple Silicon (M1) Mac while running under Rosetta 2 emulation. Homebrew is a package manager for macOS, and Rosetta 2 is a compatibility layer that allows Intel-based applications to run on Apple Silicon Macs.

Here’s a breakdown of the key components of the error

Cannot install under Rosetta 2

Specifies that the installation process is encountering difficulties while running under Rosetta 2 emulation.

in ARM default prefix (/opt/homebrew)

Indicates the default installation prefix for Homebrew on ARM-based (Apple Silicon) Macs.

To address this error, consider the following steps

Update Homebrew: Ensure that your Homebrew installation is up to date. Run the following command to update Homebrew:

brew update

Use Native Architecture

Whenever possible, try to install packages natively for the ARM architecture. This can be achieved by ensuring that Homebrew is running natively and not under Rosetta 2.

To run Homebrew natively on an Apple Silicon Mac, make sure you are using the Terminal that supports ARM. You can also use the arch command to explicitly run Homebrew with the ARM architecture:

arch -arm64 /usr/local/bin/brew install <package>

Check for ARM Compatibility

Verify whether the package you are trying to install has native support for ARM architecture. Some packages may not yet have universal support and might need to be built for ARM specifically.

Use Rosetta 2 if Necessary

If a particular package does not have native ARM support, you can use Rosetta 2 to run Homebrew in compatibility mode. However, this may not be the optimal solution for performance.

To use Rosetta 2 for Homebrew, you can prepend the arch command to the Homebrew installation command:

arch -x86_64 /usr/local/bin/brew install <package>

Check Homebrew Documentation

Refer to the Homebrew documentation and GitHub repository for any specific guidance related to running Homebrew on Apple Silicon Macs.

By following these steps, you can work towards resolving the “Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!” issue and successfully install packages using Homebrew on an Apple Silicon Mac.

Comments

  • Avatar

    Danielle Carline

    Posted on

    I fixed this error on my Mac book pro M2 (which is having Chip apple M2) by following these steps.

    As error suggests you have to install homebrew into /usr/local. This is place where intel chips use to install homebrew and /opt/homebrew/ is the place where Apple chips use to install home brew.

    I assumed you have already installed homebrew into /usr/local/bin/brew path.

    /usr/local/bin/brew tap azure/functions
    /usr/local/bin/brew install azure-functions-core-tools@4
    

    Checkout the github discussion here and stackoverflow thread here for more details about solving this error.

Write a comment

You can use the Markdown syntax to format your comment.

Tags: python