faq,

Tools - brew install the specific version of software (protobuf as an example)

中文阅读

Foreword

When installing software using homebrew under macOS, the latest version is installed by default. Sometimes when we need an old version, homebrew does not provide a more convenient way.

This article uses protobuf as an example to explain how to install the specific version of software with brew install.

Installation

Find rb file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
❯ brew info protobuf
==> protobuf: stable 21.5 (bottled), HEAD
Protocol buffers (Google's data interchange format)
https://github.com/protocolbuffers/protobuf/
/usr/local/Cellar/protobuf/3.17.3_1 (263 files, 19.3MB) *
  Poured from bottle on 2022-09-07 at 10:01:17
/usr/local/Cellar/protobuf/21.5 (279 files, 19MB)
  Poured from bottle on 2022-09-07 at 09:40:56
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/protobuf.rb
License: BSD-3-Clause
==> Dependencies
Build: python@3.10 ✘, python@3.9 ✘
==> Options
--HEAD
	Install HEAD version
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/protobuf
==> Analytics
install: 191,131 (30 days), 490,097 (90 days), 1,535,759 (365 days)
install-on-request: 46,962 (30 days), 111,247 (90 days), 316,495 (365 days)
build-error: 157 (30 days

The address of protobuf.rb obtained with brew info is https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/protobuf.rb.

Find the specific version rb file

Open the address of protobuf.rb in Browser and click History.

Find the commit of the specific version (here takes version 3.19.4 as an example), and click the commit number to view the file.

Click View file to view the file contents.

Click on Raw.

Save rb file

Save the file and name it protobuf.rb.

Here is an example of saving to the desktop.

Install the specific version of protobuf

1
2
3
4
5
6
7
❯ protoc --version
libprotoc 3.21.5
❯ cd ~/Desktop
❯ brew unlink protobuf
❯ brew install ./protobuf.rb
❯ protoc --version
libprotoc 3.19.4

Summary

Use homebrew to install other software of the specific version is a similar operation, I hope it can help everyone.


CatchZeng
Written by CatchZeng Follow
AI (Machine Learning) and DevOps enthusiast.