Mac OS 安装/卸载 Homebrew-CarlZeng

背景

介绍:https://brew.sh/index_zh-cn

macOS(或 Linux)缺失的软件包的管理器

Homebrew 能干什么? 使用 Homebrew 安装 Apple(或您的 Linux 系统)没有预装但 你需要的东西。

Homebrew 会将软件包安装到独立目录,并将其文件软链接至/opt/homebrew
Homebrew 不会将文件安装到它本身目录之外,所以您可将 Homebrew 安装到任意位置。

Homebrew 使 macOS(或您的 Linux 系统)更完整。使用 gem 来安装 RubyGems、用 brew 来安装那些依赖包。

“要安装,请拖动此图标……”不会再出现了。使用 Homebrew Cask 安装 macOS 应用程序、字体和插件以及其他非开源软件。

文档

https://github.com/homebrew/install#uninstall-homebrew

一个页面的使用说明文档:https://docs.brew.sh/Manpage#environment

解决MAC安装错误

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”

错误#1:

curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number

curl: (35) LibreSSL SSL_connect: Connection reset by peer in connection to raw.githubusercontent.com:443

解决方法:

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

错误#2:

brew -version

zsh: command not found: brew

解决方法:

==> Next steps: - Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo ‘eval “$(/opt/homebrew/bin/brew shellenv)”‘) >> /Users/carl/.zprofile
eval “$(/opt/homebrew/bin/brew shellenv)”
- Run brew help to get started - Further documentation:
https://docs.brew.sh

安装命令

brew install @@

比如:brew install gawk

安装日志

==> This script will install: /opt/homebrew/bin/brew /opt/homebrew/share/doc/homebrew /opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew /opt/homebrew/etc/bash_completion.d/brew /opt/homebrew ==> The following new directories will be created: /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /usr/bin/install -d -o root -g wheel -m 0755 /opt/homebrew ==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks ==> /usr/bin/sudo /bin/chmod ug=rwx /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks ==> /usr/bin/sudo /bin/chmod go-w /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions ==> /usr/bin/sudo /usr/sbin/chown carl /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/sbin/chown -R carl:admin /opt/homebrew ==> /usr/bin/sudo /bin/mkdir -p /Users/carl/Library/Caches/Homebrew ==> /usr/bin/sudo /bin/chmod g+rwx /Users/carl/Library/Caches/Homebrew ==> /usr/bin/sudo /usr/sbin/chown -R carl /Users/carl/Library/Caches/Homebrew
==> Downloading and installing Homebrew…
remote: Enumerating objects: 235213, done.
remote: Counting objects: 100% (129/129), done.
remote: Compressing objects: 100% (111/111), done.
remote: Total 235213 (delta 26), reused 97 (delta 12), pack-reused 235084 Receiving objects: 100% (235213/235213), 68.34 MiB | 9.51 MiB/s, done.
Resolving deltas: 100% (172493/172493), done.
From https://github.com/Homebrew/brew

  • [new branch] dependabot/bundler/Library/Homebrew/addressable-2.8.2 -> origin/dependabot/bundler/Library/Homebrew/addressable-2.8.2
  • [new branch] dependabot/bundler/Library/Homebrew/parser-3.2.2.0 -> origin/dependabot/bundler/Library/Homebrew/parser-3.2.2.0
  • [new branch] dependabot/bundler/Library/Homebrew/rubocop-1.49.0 -> origin/dependabot/bundler/Library/Homebrew/rubocop-1.49.0
  • [new branch] master -> origin/master
  • [new branch] test-runners -> origin/test-runners
  • [new tag] 0.1 -> 0.1
  • [new tag] 0.2 -> 0.2
  • [new tag] 0.3 -> 0.3
  • [new tag] 4.0.6 -> 4.0.6
  • [new tag] 4.0.7 -> 4.0.7
  • [new tag] 4.0.8 -> 4.0.8
  • [new tag] 4.0.9 -> 4.0.9
    HEAD is now at 7dbe1b487 Merge pull request #15142 from Homebrew/revert-15112-prof-group
    Warning: /opt/homebrew/bin is not in your PATH.
    Instructions on how to configure your shell for Homebrew
    can be found in the ‘Next steps’ section below. ==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations

==> Next steps: - Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo ‘eval “$(/opt/homebrew/bin/brew shellenv)”‘) >> /Users/carl/.zprofile
eval “$(/opt/homebrew/bin/brew shellenv)”

更好的Terminal命令携带代理解决方案

直接在命令行之前添加HTTPS代理信息,举例说明:
HTTPS_PROXY=”socks5://127.0.0.1:7890” lux “https://www.youtube.com/watch?v=5Dm9XTbnN-M

详见:如何使用lux,youtube-dl下载Youtube上面的音视频,油管视频(23年11月已更新)

更新DNS更新, Flush DNS

  1. On Mac: Open Finder.
  2. Click Applications.
  3. Scroll down to the Utilities folder and click it.
  4. Open Terminal.
  5. In the Terminal window, enter the following command string:
    1. sudo dscacheutil -flushcache
    2. sudo killall -HUP mDNSResponder
  6. Click enter, then input your admin password.
  7. Click enter again.

没有更新成功;

通过切换WIFI热点, 从联通切换到移动; 这样的操作会导致DNS更新.

注意到: 如果在切换回原联通的WIFI热点, ping frp.carlzeng.com依然获得旧的IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 dig frp.carlzeng.com                                                                

; <<>> DiG 9.10.6 <<>> frp.carlzeng.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47503
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;frp.carlzeng.com. IN A

;; ANSWER SECTION:
frp.carlzeng.com. 2671 IN A 125.34.235.80

;; Query time: 3 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Fri Jul 19 17:16:29 CST 2024
;; MSG SIZE rcvd: 61

参见文章: 关于DNS配置记录与分析

1
2
3
4
5
 dig frp.carlzeng.com +noall +answer -t A                                            

; <<>> DiG 9.10.6 <<>> frp.carlzeng.com +noall +answer -t A
;; global options: +cmd
frp.carlzeng.com. 2456 IN A 125.34.235.80

关闭brew自动更新

1
2
HOMEBREW_NO_AUTO_UPDATE=1
brew install wireguard-tools

运行了前面这条命了以后, brew install 就不会去检查包更新了, 省时一点

个性化需求沟通 扫客服加V加群: