HR's Blog

Swimming 🏊 in the sea🌊of code!

0%

Mac M1安装brew问题汇总

.

以下是Brew在M1电脑中遇到的问题汇总

1. 官方安装地址

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

传送门

2. brew安装源有问题

无法找到wget之类的安装包,在安装的过程中,即使常见的软件都无法找到例如wget,报错信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Warning: No available formula with the name "ca-certificates".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Running `brew update --preinstall`...
Error: No formulae found in taps.
fatal: Could not resolve HEAD to a revision
Warning: No available formula with the name "wget".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

导致的原因可能是brew的源没有正确的安装好,需要重置。

1
2
brew update-reset
brew install wget

3. 安装后还是无法找到brew命令

安装成功以后无法找到brew命令,特别是使用了zshrc中同学,需要将brew的环境加入到zshrc的配置文件中。

1
2
//安装后找不到brew, 把这个添加到.zshrc中
eval $(/opt/homebrew/bin/brew shellenv)

4. pod install 提示Ruby方面的错误描述

在M1电脑上使用cocoapod可能会出现ruby之类的错误,可以通过更改pod改回使用x86架构来解决该问题。

1
2
3
4
Update all pods
Updating local specs repositories
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275: [BUG] Bus Error at 0x0000000105158000
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
1
2
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

参考