gpt4 book ai didi

homebrew - 如何将 Homebrew 降级到旧版本?

转载 作者:行者123 更新时间:2023-12-01 23:59:42 27 4
gpt4 key购买 nike

目前我有最新版本2.2.17,我想降级到版本2.2.12

Brew 没有降级选项,只有升级选项。是卸载brew再重新安装的过程吗?

最佳答案

如果您通过安装脚本使用正常安装方式:

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

然后看看brew install script (它有自己的 repo 协议(protocol))。
它下载 actual Homebrew repo/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"
...
}
...
==> 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
...

该脚本安装 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)

我建议在确保一切正常后做一个brew doctor

然后,不幸的是,Homebrew 总是在您每次安装某些东西时自动更新。所以它总是会再次更新位于 /usr/local/Homebrew 的 repo 到最新版本。您可以通过导出 HOMEBREW_NO_AUTO_UPDATE 来禁用它,如此处所述 https://github.com/Homebrew/brew/issues/1670 .

~$ export HOMEBREW_NO_AUTO_UPDATE=1
~$ brew install python@3.8

您需要创建一个别名或自动导出该环境变量到您的 bash_profile(或您使用的终端的任何等效项),以便它在您每次使用 brew.

关于homebrew - 如何将 Homebrew 降级到旧版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62049367/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com