文章

brew安装

1. 国内安装

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

附件: Homebrew.sh

Homebrew.sh


2. 安装之后配置

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
此步骤成功

/Users/fsbook/.bash_profile:75: command not found: complete

ERROR: this script is obsolete, please see git-completion.zsh

运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew

运行代码 ==> /usr/bin/sudo /usr/sbin/chown FengShao /usr/local/Homebrew

运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew

  

==> 安装完成,brew版本

  

Homebrew 4.0.6-150-g5550aa2-dirty

fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'

To add an exception for this directory, call:

  

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

Homebrew/homebrew-core (no Git repository)

fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'

To add an exception for this directory, call:

  

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

Homebrew/homebrew-cask (no Git repository)

Brew前期配置成功

电脑系统版本:12.6

All user-space services OK, nothing cleaned...

  

  ==> brew update-reset

==> **Fetching /usr/local/Homebrew...**

  

==> **Resetting /usr/local/Homebrew...**

Updating files: 100% (2815/2815), done.

branch 'master' set up to track 'origin/master'.

Reset branch 'master'

Your branch is up to date with 'origin/master'.

  

Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask, skipping update and reset!

Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core, skipping update and reset!

Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update and reset!

  

        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/fsbook/.bash_profile   否则可能无法使用


======================================================================
极速版本安装完成, install功能正常,如果需要update功能请自行运行下面三句命令

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

brew update-reset

  

        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/fsbook/.bash_profile   否则可能无法使用

3. 安装常用工具

1
2
3
4
5
6
brew install jq coreutils bash-completion


## 特殊包名
安装工具包   命令
coreutils: gls

4. 安装报错

1. brew install openssl@3 报错: 主要是 test的时候

注: 我在手动下载源码编译的时候,跳过test是可以正常安装的

报错如下:

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
==> Installing vim dependency: openssl@3
==> perl ./Configure --prefix=/usr/local/Cellar/openssl@3/3.4.0 --openssldir=/usr/local/etc/openssl@3 --libdir=lib no-ssl3 no-ssl3-method no-zlib darwin64-x86_64-cc enable-ec_nistp_64_g
==> make
==> make install MANDIR=/usr/local/Cellar/openssl@3/3.4.0/share/man MANSUFFIX=ssl
==> make HARNESS_JOBS=4 test TESTS=-test_afalg
Last 15 lines from /Users/fengshao/Library/Logs/Homebrew/openssl@3/04.make:
90-test_store.t ......................... ok

Test Summary Report
-------------------
82-test_ocsp_cert_chain.t             (Wstat: 256 Tests: 3 Failed: 1)
  Failed test:  3
  Non-zero exit status: 1
80-test_cmp_http.t                    (Wstat: 1280 Tests: 6 Failed: 5)
  Failed tests:  1-5
  Non-zero exit status: 5
Files=323, Tests=3770, 458 wallclock secs (18.27 usr  2.31 sys + 585.20 cusr 223.52 csys = 829.30 CPU)
Result: FAIL
make[2]: *** [run_tests] Error 1
make[1]: *** [_tests] Error 2
make: *** [tests] Error 2

Do not report this issue to Homebrew/brew or Homebrew/homebrew-core!


Error: You are using macOS 12.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

Do not report this issue: you are running in an unsupported configuration.

================================================

解决方案:

1. 在编译前设置环境变量: 失败

1
2
3
HOMEBREW_NO_INSTALL_FROM_API=1 brew install openssl@3

# 但是结果还是报错,如上

2. 直接修改 Homebrew 的安装过程: 成功

a. 找到 OpenSSL 的公式文件,通常在以下路径之一:

1
2
3
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/openssl@3.rb

/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/openssl@3.rb(在 M1 或 M2 芯片的 Mac 上)

b. 在该文件中找到 def install 下面的 system “make”, “test” 这一行,并将其注释掉或删除。

c. 再运行安装命令:

1
brew install openssl@3
本文由作者按照 CC BY 4.0 进行授权