如果您通过安装脚本使用正常安装方式:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Run Code Online (Sandbox Code Playgroud)
然后看一下brew安装脚本(它有自己的存储库)。
它将实际的 Homebrew 存储库下载到/usr/local/Homebrew。
...
HOMEBREW_PREFIX="/usr/local"
HOMEBREW_REPOSITORY="/usr/local/Homebrew"
...
BREW_REPO="https://github.com/Homebrew/brew"
...
ohai "Downloading and installing Homebrew..."
(
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
# "git remote add" will fail if the remote is defined in the global config
execute "git" "config" "remote.origin.url" "${BREW_REPO}"
execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"
...
execute "ln" "-sf" "${HOMEBREW_REPOSITORY}/bin/brew" "${HOMEBREW_PREFIX}/bin/brew"
...
}
...
Run Code Online (Sandbox Code Playgroud)
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
...
Run Code Online (Sandbox Code Playgroud)
该脚本会安装 Homebrew 存储库的最新副本。因此,“是否需要卸载brew并重新安装它? ”的答案是“否”。相反,首先正常安装它,然后转到/usr/local/Homebrew并检查您想要的版本。
~$ cd /usr/local/Homebrew
Homebrew$ brew --version
Homebrew 2.3.0
Homebrew/homebrew-core (git revision d41d92; last commit 2020-05-29)
Homebrew$ git fetch --tags
Homebrew$ git checkout 2.2.12
Note: switching to '2.2.12'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 2ae26808a Merge pull request #7301 from Bo98/cmake-sdkroot
Homebrew$ brew --version
Homebrew 2.2.12
Homebrew$ cd /usr/local/bin
bin$ ./brew --version
Homebrew 2.2.12
Homebrew/homebrew-core (git revision d41d92; last commit 2020-05-29)
Run Code Online (Sandbox Code Playgroud)
我建议做一次brew doctor以确保一切都还好。
然后,不幸的是,每次您安装某些东西时,Homebrew 总是会自动更新。因此它总是会再次将/usr/local/Homebrew中的存储库更新到最新版本。HOMEBREW_NO_AUTO_UPDATE您可以通过此处提到的导出来禁用它https://github.com/Homebrew/brew/issues/1670。
~$ export HOMEBREW_NO_AUTO_UPDATE=1
~$ brew install python@3.8
Run Code Online (Sandbox Code Playgroud)
您需要创建一个别名或将该环境变量自动导出到您的 bash_profile (或您使用的终端的等效项),以便它在您每次使用时生效brew。
| 归档时间: |
|
| 查看次数: |
8158 次 |
| 最近记录: |