解决Mac下安装Homebrew慢的问题

2023-05-16

一、方法一

国内安装Homebrew很慢,可以使用下面的方法:

curl -fsSL https://gitee.com/xueweihan/codes/vfrgh7z8qcjlx1ubwt6nk71/raw\?blob_name\=brew_install.sh >> brew_install

先把安装文件保存到brew_install,然后修改其中的仓库地址,打开 brew_install 文件,把
BREW_REPO后面引号内的地址改为:

https://mirrors.ustc.edu.cn/brew.git

或者

https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

如果有CORE_TAP_REPO,则把引号内的地址改为:

https://mirrors.ustc.edu.cn/homebrew-core.git

或者

https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

如果没有CORE_TAP_REPO也不用新增。
执行下面的命令开始安装:

/usr/bin/ruby brew_install

安装到显示:

==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

在这里插入图片描述
时,可能会比较慢了,此时中断安装。手动执行:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

上面的git地址可以使用前面CORE_TAP_REPO的两个地址中任意一个。

然后再把homebrew-core的地址也改为国内的镜像地址:

cd $(brew --repo)
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

或者:

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git

安装完成后再更新一下:

brew update

检测一下是否有问题:

brew doctor

在这里插入图片描述
我的就检测到一些警告,不过不影响。

为了让Homebrew安装软件时速度更快,需要替换Homebrew-bottles的地址,使用:

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

临时替换。如果Mac是终端用的bash,使用

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

进行永久替换,如果终端用的是zsh,把bash_profile改为zshrc即可。

方法二

如果上面的镜像还是比较慢,可以再使用下面的命令更换为新的镜像地址mirrors.ustc.edu.cn:

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

方法三

可以使用下面的命令设置为国内镜像

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

下面为笔者运行情况:

$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

               开始执行Brew自动安装程序 
              [cunkai.wang@foxmail.com] 
           ['2021-10-01 22:02:07']['10.12']
        https://zhuanlan.zhihu.com/p/111014448 


请选择一个下载镜像,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。cask非必须,有部分人需要。
1、中科大下载源 2、清华大学下载源 3、北京外国语大学下载源  4、腾讯下载源(不推荐) 5、阿里巴巴下载源(不推荐 缺少cask源)  

请输入序号: 1


  你选择了中国科学技术大学下载源
  
!!!此脚本将要删除之前的brew(包括它下载的软件),请自行备份。
->是否现在开始执行脚本(N/Y) y

--> 脚本开始执行
 Mac os设置开机密码方法:
  (设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码)
  (如果提示This incident will be reported. 在用户与群组中查看是否管理员) 
==> 通过命令删除之前的brew、创建一个新的Homebrew文件夹
请输入开机密码,输入过程不显示,输入完后回车
Password:
开始执行
  ---备份要删除的/usr/local/Homebrew到系统桌面....
cp: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/fuse/fuse.pc: No such file or directory
cp: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/fuse/osxfuse.pc: No such file or directory
   ---/usr/local/Homebrew 备份完成
-> 创建文件夹 /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Homebrew
此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown witton /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew
  ---备份要删除的/Users/witton/Library/Caches/Homebrew到系统桌面....
cp: /Users/witton/Library/Caches/Homebrew/Backup/bin/idle3: No such file or directory
cp: /Users/witton/Library/Caches/Homebrew/Backup/bin/pydoc3: No such file or directory
cp: /Users/witton/Library/Caches/Homebrew/Backup/bin/python3: No such file or directory
cp: /Users/witton/Library/Caches/Homebrew/Backup/bin/python3-config: No such file or directory
cp: /Users/witton/Library/Caches/Homebrew/Backup/lib/pkgconfig/python3.pc: No such file or directory
cp: /Users/witton/Library/Caches/Homebrew/Backup/share/man/man1/python3.1: No such file or directory
   ---/Users/witton/Library/Caches/Homebrew 备份完成
  ---备份要删除的/Users/witton/Library/Logs/Homebrew到系统桌面....
   ---/Users/witton/Library/Logs/Homebrew 备份完成
git version 2.14.3 (Apple Git-98)

下载速度觉得慢可以ctrl+c或control+c重新运行脚本选择下载源
==> 克隆Homebrew基本文件

未发现Git代理(属于正常状态)
Cloning into '/usr/local/Homebrew'...
remote: Enumerating objects: 201010, done.
remote: Total 201010 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (201010/201010), 52.37 MiB | 4.42 MiB/s, done.
Resolving deltas: 100% (149886/149886), done.
此步骤成功
--创建Brew所需要的目录
运行代码 ==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin/brew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin/brew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/sbin/chown witton /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R witton:admin /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /Users/witton/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /Users/witton/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R witton /Users/witton/Library/Caches/Homebrew
--依赖目录脚本运行完成
==> 创建brew的替身
==> 克隆Homebrew Core
此处如果显示Password表示需要再次输入开机密码,输入完后回车
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1048692, done.
remote: Total 1048692 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1048692/1048692), 426.79 MiB | 3.12 MiB/s, done.
Resolving deltas: 100% (726438/726438), done.
此步骤成功
==> 克隆Homebrew Cask 图形化软件
  此处如果显示Password表示需要再次输入开机密码,输入完后回车
Password:
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 646355, done.
remote: Total 646355 (delta 0), reused 0 (delta 0)B | 4.13 MiB/s   
Receiving objects: 100% (646355/646355), 281.75 MiB | 4.09 MiB/s, done.
Resolving deltas: 100% (461968/461968), done.
此步骤成功
==> 克隆Homebrew services 管理服务的启停
  
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1141, done.
remote: Total 1141 (delta 0), reused 0 (delta 0), pack-reused 1141
Receiving objects: 100% (1141/1141), 331.50 KiB | 563.00 KiB/s, done.
Resolving deltas: 100% (484/484), done.
此步骤成功
==> 配置国内镜像源HOMEBREW BOTTLE
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /Users/witton/.bash_profile
运行代码 ==> /usr/bin/sudo /usr/sbin/chown witton /Users/witton/.bash_profile
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /Users/witton/.bash_profile
环境变量写入->/Users/witton/.bash_profile
此步骤成功
WARNING: this script is deprecated, please see git-completion.zsh
compinit:498: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown witton /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew

==> 安装完成,brew版本

Homebrew 3.2.14-45-gd6eb9ec-dirty
Homebrew/homebrew-core (git revision 4a7c870b593; last commit 2021-10-01)
Homebrew/homebrew-cask (git revision f6cb1d8826; last commit 2021-10-01)
Brew前期配置成功
检测到你不是最新系统,会有一些报错,请稍等Ruby下载安装;
      
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
All user-space services OK, nothing cleaned...

  ==> brew update-reset
  
==> Fetching /usr/local/Homebrew...

==> Resetting /usr/local/Homebrew...
Branch master set up to track remote branch master from origin.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Branch master set up to track remote branch master from origin.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Branch master set up to track remote branch master from origin.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.

==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...

==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...
Branch master set up to track remote branch master from origin.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.


        Brew自动安装程序运行完成
          国内地址已经配置完成

  桌面的Old_Homebrew文件夹,大致看看没有你需要的可以删除。

              初步介绍几个brew命令
本地软件库列表:brew ls
查找软件:brew search google(其中google替换为要查找的关键字)
查看brew版本:brew -v  更新brew版本:brew update
安装cask软件:brew install --cask firefox 把firefox换成你要安装的
        
        欢迎右键点击下方地址-打开URL 来给点个赞
         https://zhuanlan.zhihu.com/p/111014448 

 重启终端 或者 运行 source /Users/witton/.bash_profile   否则可能无法使用

参考:
https://www.zhihu.com/question/35928898
https://blog.csdn.net/DiyHzp/article/details/90763558
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew-bottles/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解决Mac下安装Homebrew慢的问题 的相关文章

随机推荐

  • stm32无法烧录问题分析

    1 开始能烧录 xff0c 烧录程序后就不能烧录了 原因 xff1a 升级接口IO被代码修改应用 xff0c 导致无法烧录 xff0c 解决办法 xff1a 可以让MCU进入升级模式 xff08 拉高boot0 xff0c 然后复位MCU
  • 【Git】msysgit + TortoiseGit:在 windows 上安装配置版本控制工具 Git 图形化使用

    msysgit 43 TortoiseGit xff1a 在 windows 上安装配置版本控制工具 Git 图形化使用 一 安装说明 Git 是 Linux Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控
  • Slickedit使用记录

    Slickedit使用记录 一 快捷键二 问题和解决方法 一 快捷键 已经习惯了android studio 中的快捷键 xff0c 在slickedit上也做下修改Tools gt options gt Keyboard and mous
  • 查看.Net源代码vs版本号

    方法 xff1a 用记事本打开vs项目的 sln文件 第2行就是这个源代码包的开发软件vs版本号了 Microsoft Visual Studio Solution File Format Version 9 00 Visual Studi
  • Docker: GUI 应用,Ubuntu 上如何运行呢?

    操作系统 Ubuntu 18 04运行镜像 continuumio anaconda3 based on debian Step 1 安装 Docker span class token comment update the apt pac
  • 网络爬虫详细设计方案

    目录 网络爬虫设计方案 1 网络爬虫简介 2 Java爬虫的开发和使用流程 2 1 下载 2 2 分析 3 单点登陆与Jsoup解析 3 1 单点登陆简介 3 1 1 登陆 3 1 2 注销 3 2 Jsoup网页解析 4 网络爬虫详细设计
  • 安装 python-dev 的时候,缺少依赖关系

    sudo aptitude install python dev报错 xff1a 下列软件包有未满足的依赖关系 xff1a python dev 依赖 libpython dev 61 2 7 5 5ubuntu3 但是它将不会被安装 依赖
  • maven-replacer-plugin 静态资源打包方案js css

    解决问题 xff1a 防止浏览器缓存 xff0c 修改js css后无效 xff0c 需要强刷 两种解决方案 xff1a 1 不依赖插件 xff0c 纯代码实现 1 1 实现拦截处理器 xff1a ModelAndViewIntercept
  • 简单FTP构建及访问

    使用2台RHEL6虚拟机 xff0c 其中一台作为vsftpd服务器 xff08 192 168 4 5 xff09 另外一台作为测试用的Linux客户机 xff08 192 168 4 205 xff09 在RHEL6系统中 xff0c
  • freertos程序死机原因

    一 开机死机原因 1 一般是某任务栈溢出所致 栈溢出一般有两个原因 xff1a 1 此任务函数的代码量太大 或调用了某个比较大的函数 2 此任务的函数内有比较大的局部变量的数组 调试方法 xff1a 1 先关闭所有任务再逐个打开 xff0c
  • 安装在win10环境下的Jenkins添加本地虚拟机centos7作为从机遇到的问题,报错:SSH Connection failed with IOException: "Key exchange

    首先声明我的Jenkins版本是 xff1a 2 31版 因为不同版本页面有所不一样 安装在win10环境下的Jenkins添加本地虚拟机centos7作为从机遇到的问题 xff0c 报错情况如下 xff1a Searching for 1
  • Linux du命令和df命令区别

    1 xff0c 两者区别 du xff0c disk usage 是通过搜索文件来计算每个文件的大小然后累加 xff0c du能看到的文件只是一些当前存在的 xff0c 没有被删除的 他计算的大小就是当前他认为存在的所有文件大小的累加和 d
  • ML大杂烩:**常见机器学习算法公式梳理

    机器学习方法有一个进阶的过程 xff0c 不同的方法族 xff0c 都有其基础和逐渐进化的模型 每一个更新的模型一般是对上一个简单模型的改进 xff0c 比如SVM就直接改进了近邻方法 xff0c 降低了保留的实例个数 本文有大量修改 xf
  • libuv笔记 (一)Threads

    Threads 线程在现代程序开发中会很常见 xff0c 当然Libuv也不能缺席这一块 xff0c 记得你在使用过程中要非常认真的处理 各种原始的同步问题 线程会在内部使用 xff0c 用来在执行系统调用时伪造异步的假象 libuv通过线
  • SLAM: SLAM基本流程—VSLAM扫盲之旅

    在很多机器人的论文和书籍里面 xff0c 劈头第一页即是 xff0c 经典的SLAM视觉框架是过去十几年前已经成熟的研究结果 xff0c 这个框架和算法本身已经没有太多理论可以操作的空间 封杀了很多人的SLAM科研之路 xff0c 把SLA
  • 三维重建:SLAM的尺度和方法论问题

    百度百科的定义 此文引用了其他博客的一些图像 xff0c 如有侵权 xff0c 邮件联系删除 作为算法的SLAM xff0c 被称为同步相机位姿确定和地图构建 作为一个工程的SLAM xff0c 有众多的算法 在计算机视觉中 三维重建是指根
  • 相机标定:PNP基于单应面解决多点透视问题

    利用二维视野内的图像 xff0c 求出三维图像在场景中的位姿 xff0c 这是一个三维透视投影的反向求解问题 常用方法是PNP方法 xff0c 需要已知三维点集的原始模型 本文做了大量修改 xff0c 如有不适 xff0c 请移步原文 xf
  • 三维重建7:Visual SLAM算法笔记

    VSLAM研究了几十年 xff0c 新的东西不是很多 xff0c 三维重建的VSLAM方法可以用一篇文章总结一下 此文是一个好的视觉SLAM综述 xff0c 对视觉SLAM总结比较全面 xff0c 是SLAM那本书的很好的补充 介绍了基于滤
  • 基于stm32c8t6的两轮平衡小车 第二篇——原理图及CubeMx配置

    目录 1 原理图 2 CubeMx配置 xff08 1 xff09 创建工程 xff08 2 xff09 配置时钟树 xff08 3 xff09 仿真模式选择 xff08 4 xff09 TIM2配置为PWM输出模式 xff08 5 xff
  • 解决Mac下安装Homebrew慢的问题

    一 方法一 国内安装Homebrew很慢 xff0c 可以使用下面的方法 xff1a span class token function curl span fsSL https gitee com xueweihan codes vfrg