我用的是最新的苹果M1芯片处理器。在安装应用程序时,我总是出错。

说,

brew install openjdk@11
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

需要帮助,知道具体的步骤。


当前回答

这里的回复中有很多有用的信息,但似乎没有对原始请求的直接回答,“需要帮助,需要遵循确切的步骤。”

为了帮助将来遇到这个问题的人,我将分享我解决这个问题的具体步骤。

下面的CLI命令将在内置的终端应用程序中运行macos默认shell Zsh,运行在苹果硅设备的Mac上:

Run a Homebrew command to confirm that an error like the following appears: $ brew install <formula> Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! Please create a new installation in /opt/homebrew using one of the "Alternative Installs" from: https://docs.brew.sh/Installation Or: $ brew doctor Warning: Your Homebrew's prefix is not /opt/homebrew. Some of Homebrew's bottles (binary packages) can only be used with the default prefix (/opt/homebrew). You will encounter build failures with some formulae. If either of these errors appears, it is likely that the steps below are applicable to your case. Navigate to the /opt folder: $ cd /opt Create a folder named homebrew. By default superuser privileges are required to write inside of the /opt folder, which means that it is necessary to use sudo: $ sudo mkdir homebrew Grant write access to the homebrew folder so that your user can perform the Homebrew installation: $ sudo chmod go+w homebrew Perform the four steps listed on the "Alternative Installs" page (the page mentioned in the first error message in step 1): Install Homebrew: $ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew Set Homebrew's prefix in your current Terminal session: $ eval "$(homebrew/bin/brew shellenv)" Update Homebrew: $ brew update --force --quiet Revoke write access to specific folders and files: $ chmod -R go-w "$(brew --prefix)/share/zsh" Set Homebrew's prefix in future Terminal sessions by adding the necessary command to one of Zsh's startup files. As far as I can tell, .zshrc is the preferred startup file for this type of command: $ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc Note that if there are any other existing Terminal sessions on your machine that have been open since before running the above command, the correct Homebrew prefix will still be unset in those sessions. Confirm that Homebrew's prefix is now properly set: $ type -a brew brew is /opt/homebrew/bin/brew brew is /usr/local/bin/brew Or: $ brew doctor Your system is ready to brew.

现在应该可以继续正常使用Homebrew了。

其他回答

运行此命令将解决问题

arch -arm64 brew install kotlin

这里的回复中有很多有用的信息,但似乎没有对原始请求的直接回答,“需要帮助,需要遵循确切的步骤。”

为了帮助将来遇到这个问题的人,我将分享我解决这个问题的具体步骤。

下面的CLI命令将在内置的终端应用程序中运行macos默认shell Zsh,运行在苹果硅设备的Mac上:

Run a Homebrew command to confirm that an error like the following appears: $ brew install <formula> Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! Please create a new installation in /opt/homebrew using one of the "Alternative Installs" from: https://docs.brew.sh/Installation Or: $ brew doctor Warning: Your Homebrew's prefix is not /opt/homebrew. Some of Homebrew's bottles (binary packages) can only be used with the default prefix (/opt/homebrew). You will encounter build failures with some formulae. If either of these errors appears, it is likely that the steps below are applicable to your case. Navigate to the /opt folder: $ cd /opt Create a folder named homebrew. By default superuser privileges are required to write inside of the /opt folder, which means that it is necessary to use sudo: $ sudo mkdir homebrew Grant write access to the homebrew folder so that your user can perform the Homebrew installation: $ sudo chmod go+w homebrew Perform the four steps listed on the "Alternative Installs" page (the page mentioned in the first error message in step 1): Install Homebrew: $ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew Set Homebrew's prefix in your current Terminal session: $ eval "$(homebrew/bin/brew shellenv)" Update Homebrew: $ brew update --force --quiet Revoke write access to specific folders and files: $ chmod -R go-w "$(brew --prefix)/share/zsh" Set Homebrew's prefix in future Terminal sessions by adding the necessary command to one of Zsh's startup files. As far as I can tell, .zshrc is the preferred startup file for this type of command: $ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc Note that if there are any other existing Terminal sessions on your machine that have been open since before running the above command, the correct Homebrew prefix will still be unset in those sessions. Confirm that Homebrew's prefix is now properly set: $ type -a brew brew is /opt/homebrew/bin/brew brew is /usr/local/bin/brew Or: $ brew doctor Your system is ready to brew.

现在应该可以继续正常使用Homebrew了。

转到https://brew.sh并使用该命令。它将再次正确地下载和安装brew。

在终端上运行这个程序就能解决问题

eval “$(/opt/homebrew/bin/brew shellenv)”

无论如何,在安装Homebrew之前,您需要为新的ARM硅(M1芯片)安装Rosetta2模拟器。我刚刚通过终端安装了Rosetta2,使用:

/usr/sbin/softwareupdate——install-rosetta——同意授权

这将安装rosetta2,无需额外单击按钮。

在安装上面的Rosetta2之后,您可以使用Homebrew cmd并安装Homebrew for ARM M1 chip: arch -x86_64 /bin/bash -c "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

一旦安装了Homebrew for M1 ARM,使用以下Homebrew命令安装包