主页
文章
分类
系列
标签
Homebrew 安装
发布于: 2018-11-23   更新于: 2018-11-23   收录于: 软件安装 , Mac
文章字数: 1970   阅读时间: 4 分钟  

Homebrew 是一款免费开源的软件包管理工具,可在 macOS 和 Linux 等操作系统上安装、卸载和管理软件包。它提供了一个简单的命令行界面,可以让用户轻松安装、卸载和更新各种软件包。

Homebrew 官网

国内源安装

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

安装过程如下

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
andyqiu@Andy-MacBook-Pro ~ % /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

               开始执行Brew自动安装程序 
              [cunkai.wang@foxmail.com] 
           ['2023-02-18 19:56:46']['11.7']
        https://zhuanlan.zhihu.com/p/111014448 


请选择一个下载brew本体的序号,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。
1、中科大下载源
2、清华大学下载源
3、北京外国语大学下载源 
4、腾讯下载源 
5、阿里巴巴下载源 
请输入序号: 1


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

--> 脚本开始执行
 Mac os设置开机密码方法:
  (设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码)
  (如果提示This incident will be reported. 在用户与群组中查看是否管理员) 
==> 通过命令删除之前的brew、创建一个新的Homebrew文件夹
请输入开机密码,输入过程不显示,输入完后回车
Password:
开始执行
  ---备份要删除的/usr/local/Homebrew到系统桌面....
   ---/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 andyqiu /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew
  ---备份要删除的/Users/andyqiu/Library/Caches/Homebrew到系统桌面....
   ---/Users/andyqiu/Library/Caches/Homebrew 备份完成
  ---备份要删除的/Users/andyqiu/Library/Logs/Homebrew到系统桌面....
   ---/Users/andyqiu/Library/Logs/Homebrew 备份完成
git version 2.32.0 (Apple Git-132)

下载速度觉得慢可以ctrl+c或control+c重新运行脚本选择下载源
==> 从 https://mirrors.ustc.edu.cn/brew.git 克隆Homebrew基本文件

未发现Git代理(属于正常状态)
Cloning into '/usr/local/Homebrew'...
remote: Enumerating objects: 235034, done.
remote: Total 235034 (delta 0), reused 0 (delta 0), pack-reused 235034
Receiving objects: 100% (235034/235034), 63.73 MiB | 16.55 MiB/s, done.
Resolving deltas: 100% (174777/174777), 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 /usr/sbin/chown -R andyqiu:admin /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /Users/andyqiu/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /Users/andyqiu/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R andyqiu /Users/andyqiu/Library/Caches/Homebrew
--依赖目录脚本运行完成
==> 创建brew的替身
==> 从 https://mirrors.ustc.edu.cn/homebrew-core.git 克隆Homebrew Core
此处如果显示Password表示需要再次输入开机密码,输入完后回车
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1418954, done.
remote: Total 1418954 (delta 0), reused 0 (delta 0), pack-reused 1418954
Receiving objects: 100% (1418954/1418954), 643.43 MiB | 4.56 MiB/s, done.
Resolving deltas: 100% (1002247/1002247), done.
Updating files: 100% (6870/6870), done.
此步骤成功
==> 从 https://mirrors.ustc.edu.cn/homebrew-cask.git 克隆Homebrew Cask 图形化软件
  此处如果显示Password表示需要再次输入开机密码,输入完后回车
Password:
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 761062, done.
remote: Total 761062 (delta 0), reused 0 (delta 0), pack-reused 761062
Receiving objects: 100% (761062/761062), 380.78 MiB | 8.36 MiB/s, done.
Resolving deltas: 100% (547180/547180), done.
此步骤成功
==> 从 https://gitee.com/cunkai/homebrew-services.git 克隆Homebrew services 管理服务的启停
  
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 2041, done.
remote: Counting objects: 100% (900/900), done.
remote: Compressing objects: 100% (447/447), done.
remote: Total 2041 (delta 450), reused 877 (delta 430), pack-reused 1141
Receiving objects: 100% (2041/2041), 555.72 KiB | 427.00 KiB/s, done.
Resolving deltas: 100% (934/934), done.
此步骤成功
==> 配置国内镜像源HOMEBREW BOTTLE
sed: /Users/andyqiu/.zprofile: No such file or directory


            Brew本体已经安装成功,接下来配置国内源。

请选择今后brew install的时候访问那个国内镜像,例如阿里巴巴,输入5回车。

1、中科大国内源
2、清华大学国内源
3、北京外国语大学国内源
4、腾讯国内源 
5、阿里巴巴国内源 
请输入序号: 4


    你选择了腾讯国内源
    


        环境变量写入->/Users/andyqiu/.zprofile


此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown andyqiu /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew

==> 安装完成,brew版本

Homebrew 4.0.1-60-g6ad9294-dirty
Homebrew/homebrew-core (git revision 80197949244; last commit 2023-02-18)
Homebrew/homebrew-cask (git revision 2ae4c0cc5f; last commit 2023-02-18)
Brew前期配置成功
电脑系统版本:11.7
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles-portable-ruby/portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz
-#O=#    #      #                                                                                                                                                             
curl: (22) The requested URL returned error: 404 Not Found
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:1f50bf80583bd436c9542d4fa5ad47df0ef0f0bea22ae710c4f04c42d7560bca
######################################################################################################################################################################## 100.0%
==> Pouring portable-ruby-2.6.8_1.el_capitan.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...
Updating files: 100% (4221/4221), done.
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...
Updating files: 100% (6578/6578), done.
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/andyqiu/.zprofile   否则可能无法使用
  
andyqiu@Andy-MacBook-Pro ~ % source /Users/andyqiu/.zprofile
andyqiu@Andy-MacBook-Pro ~ %