brewで旧バージョンをインストールする


# brewで旧バージョンをインストールする

## icu4cで発生したエラー
インストールしたものが新しい（もしくは、更新したら新しくなってしまった）ために、ビルドが通らなくなった、

```
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicuio.68.dylib
```

確かに、69がインストールされている

```
% brew info icu4c
icu4c: stable 69.1 (bottled) [keg-only]
C/C++ and Java libraries for Unicode and globalization
http://site.icu-project.org/home
/usr/local/Cellar/icu4c/69.1 (259 files, 72.8MB)
  Poured from bottle on 2021-10-08 at 15:53:45
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/icu4c.rb
License: ICU
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH, run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Analytics
install: 320,240 (30 days), 934,556 (90 days), 4,459,523 (365 days)
install-on-request: 5,047 (30 days), 15,107 (90 days), 99,387 (365 days)
build-error: 0 (30 days)

%  ls /usr/local/opt/icu4c/lib/
icu			libicuio.69.1.dylib	libicutu.69.dylib
libicudata.69.1.dylib	libicuio.69.dylib	libicutu.a
libicudata.69.dylib	libicuio.a		libicutu.dylib
libicudata.a		libicuio.dylib		libicuuc.69.1.dylib
libicudata.dylib	libicutest.69.1.dylib	libicuuc.69.dylib
libicui18n.69.1.dylib	libicutest.69.dylib	libicuuc.a
libicui18n.69.dylib	libicutest.a		libicuuc.dylib
libicui18n.a		libicutest.dylib	pkgconfig
libicui18n.dylib	libicutu.69.1.dylib
```

## 旧バージョン(68)を入れたい！

brew tap-newとかbrew extractを使うやり方

```
% brew tap-new icu4c/taps #「icu4c」の部分はなんでもok
Warning: tap-new is a developer command, so
Homebrew's developer mode has been automatically turned on.
To turn developer mode off, run brew developer off

Initialized empty Git repository in /usr/local/Homebrew/Library/Taps/icu4c/homebrew-taps/.git/
[master (root-commit) 31051f7] Create icu4c/taps tap
 3 files changed, 88 insertions(+)
 create mode 100644 .github/workflows/publish.yml
 create mode 100644 .github/workflows/tests.yml
 create mode 100644 README.md
==> Created icu4c/taps
/usr/local/Homebrew/Library/Taps/icu4c/homebrew-taps

When a pull request making changes to a formula (or formulae) becomes green
(all checks passed), then you can publish the built bottles.
To do so, label your PR as `pr-pull` and the workflow will be triggered.
```

旧バージョン(68)をtapにする

```
% brew extract icu4c icu4c/taps --version 68
==> Searching repository history
==> Writing formula for icu4c from revision 284ffd9 to:
/usr/local/Homebrew/Library/Taps/icu4c/homebrew-taps/Formula/icu4c@68.rb
```

旧バージョン(68)をインストール


```
% brew install icu4c/taps/icu4c@68
==> Downloading https://github.com/unicode-org/icu/releases/download/release-68-
Already downloaded: /Users/kaihei777/Library/Caches/Homebrew/downloads/f9101dc8dedeffd29c43df0042f53e616a8ef85354be59a88b3fdbe1e5be9b9d--icu4c-68_2-src.tgz
==> Installing icu4c@68 from icu4c/taps
==> ./configure --prefix=/usr/local/Cellar/icu4c@68/68.2 --disable-samples --dis
==> make
==> make install
==> Caveats
icu4c@68 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c@68 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/icu4c@68/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c@68/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c@68 you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c@68/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c@68/include"

For pkg-config to find icu4c@68 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c@68/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/icu4c@68/68.2: 259 files, 72.5MB, built in 4 minutes 41 seconds
```

インストールされる場所が、変わっているのでパスを通す必要があります。

/usr/local/opt/icu4c　#ここは、69
/usr/local/opt/icu4c@68 #こちらが、68