温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么在Mac M1中安装Homebrew

发布时间:2021-03-25 15:29:45 来源:亿速云 阅读:682 作者:Leah 栏目:开发技术

怎么在Mac M1中安装Homebrew?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

常用命令

搜索软件: brew search 软件包名称

安装软件: brew install 软件包名称

卸载软件: brew uninstall 软件包名称

错误解决

问题1 : curl: (7) Failed to connect to http://raw.githubusercontent.com port 443: Connection refused” 错误

解决方法:

打开 www.ipaddress.com 网站查询 raw.githubusercontent.com 主机的真实IP

怎么在Mac M1中安装Homebrew

打开 /etc/hosts 文件,增加一条记录

185.199.108.133  raw.githubusercontent.com

问题2 :如果 brew install 出以下错误, 则安装时使用 arch -arm64 brew install 软件包名 进行安装

怎么在Mac M1中安装Homebrew

创建安装目录

Homebrew 安装脚本会将程序默认装至 /usr/local/Homebrew ,这是 Intel 芯片架构上的安装路径,M1芯片上则需要安装到 /opt/Homebrew/ 下。

sudo mkdir -p /opt/homebrew
sudo chown -R $(whoami) /opt/homebrew

下载 homebrew 包并解压至 /opt/homebrew 目录

curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

如果下载慢,可以直接通过 https://github.com/Homebrew/brew/tarball/master 或本地下载,copy 到 /opt 目录下再将压缩包解压到 /opt/homebrew 目录

cp /opt
tar xz 压缩包名 --strip 1 -C homebrew

将路径增加到PATH环境变量中

vim ~/.bash_profile
#在 .bash_profile 中新增
export PATH=$PATH:/opt/homebrew/bin;
#保存退出
#刷新生效
source ~/.bash_profile

修改源

cd "$(brew --repo)"
git clone https://mirrors.ustc.edu.cn/brew.git
 
 
cd "$(brew --repo)/Library/Taps/homebrew"
 
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
 
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
 
brew update #更新

其它镜像地址:

HomeBrew 官方镜像:
brew: https://github.com/Homebrew/brew
core: https://github.com/Homebrew/homebrew-core
cask: https://github.com/Homebrew/homebrew-cask

清华大学镜像:
brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
cask: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

中科大镜像:
brew: https://mirrors.ustc.edu.cn/brew.git
core: https://mirrors.ustc.edu.cn/homebrew-core.git
cask: https://mirrors.ustc.edu.cn/homebrew-cask.git

终于可以进行下载软件了

brew install -s 软件包名

关于怎么在Mac M1中安装Homebrew问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI