brew安装多版本 清理包和 img

brew 安装多版本

例子,当前 gradle 5.2.1 ,想将 4.10.2 装上,找到 formula 的 git 目录,切到对应 4.10.2 的 commit,安装,安装完之后再切回 master

$ brew list gradle --versions
gradle 5.2.1
$ cd "$(brew --repo homebrew/core)"
$ pwd
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
$ git log master -- Formula/gradle.rb 
...
commit 01e0511df2c37b052a9659797f3c09df3f20d533
Author: Jerome Lapostolet 
Date:   Thu Sep 20 08:51:53 2018 +0100

    gradle 4.10.2
...

$ git checkout 01e0511df2c37b052a9659797f3c09df3f20d533
Note: checking out '01e0511df2c37b052a9659797f3c09df3f20d533'.

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 performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b 

HEAD is now at 01e0511df2 gradle 4.10.2
$ HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle
Error: gradle 5.2.1 is already installed
To install 4.10.2, first run `brew unlink gradle`.
$ HOMEBREW_NO_AUTO_UPDATE=1 brew unlink gradle
Unlinking /usr/local/Cellar/gradle/5.2.1... 1 symlinks removed
$ HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle
==> Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip
==> Downloading from https://downloads.gradle.org/distributions/gradle-4.10.2-all.zip
######################################################################## 100.0%
🍺  /usr/local/Cellar/gradle/4.10.2: 203 files, 83.7MB, built in 5 minutes 56 seconds
$ git checkout master

$ brew list gradle --versions
gradle 5.2.1 4.10.2

之后可以用 brew swith gradle x.x.x 在不同版本之间切换

查看已经安装的包

brew list

选择要清理的包

brew uninstall mariadb

整体清理

brew update && brew upgrade && brew cleanup

==> This operation has freed approximately 427.8M of disk space.
brew cask cleanup

https://brew.sh/ 搜索软件和版本

参考:
https://www.cnblogs.com/BlackStorm/p/homebrew-install-old-versions-take-node-for-example.html

留下评论

电子邮件地址不会被公开。 必填项已用*标注