brewでインストールしたpostgres@10で、psqlでエラーが出た話し

えーと・・・[mysqlのとき](https://qiita.com/Chazken/items/13b8a56560108bdfcbd6)と似たような目にあいました。Montery(ver. 12.3) のmacに、brewでpostgres@10をインストールすると

```zsh
% psql
Error
dyld[93190]: Library not loaded: /usr/local/opt/readline/lib/libreadline.8.dylib
```

このあとのpostgresql用も含め、シンボリックリンクを二つ作る必要がありました。

```zsh
cd /usr/local/opt
ln -s ../Cellar/readline/8.1.2 readline
ln -s ../Cellar/icu4c/70.1 icu4c
```

このあと、postgresのコマンドinitdbでディレクトリとかを初期化します。

```zsh
% /usr/local/opt/postgresql@10/bin/initdb /usr/local/var/postgres -E utf8
```

##### 蛇足

なんか/usr/local/optの下に、../Cellar/xxx/yyyy以下宛のリンクがごっそり抜けている印象があります。brew listで出てくる名前で

```zsh
brew link xxxx
```
とやると、シンボリックリンクを貼ってくれるのですが、これまでインストールした全部を一気にやってくれるコマンドは見当たりません。とりあえずこんなんでやってみる。

```zsh
% brew list | awk '{system("brew link "$1)}'

Linking /usr/local/Cellar/ca-certificates/2022-02-01... 1 symlinks created.
Linking /usr/local/Cellar/cairo/1.16.0_5... 31 symlinks created.
Linking /usr/local/Cellar/fontconfig/2.13.1... 243 symlinks created.
Linking /usr/local/Cellar/fontforge/20220308... 23 symlinks created.
Linking /usr/local/Cellar/freetype/2.11.1... 8 symlinks created.
Linking /usr/local/Cellar/fribidi/1.0.11... 37 symlinks created.
Linking /usr/local/Cellar/gdbm/1.23... 17 symlinks created.
Linking /usr/local/Cellar/gettext/0.21... 123 symlinks created.
Linking /usr/local/Cellar/giflib/5.2.1... 11 symlinks created.
Linking /usr/local/Cellar/glib/2.70.4... 51 symlinks created.
Linking /usr/local/Cellar/gobject-introspection/1.70.0_3... 17 symlinks created.
Linking /usr/local/Cellar/graphite2/1.3.14... 7 symlinks created.
Linking /usr/local/Cellar/harfbuzz/4.0.1... 
Error: Could not symlink share/gir-1.0/HarfBuzz-0.0.gir
Target /usr/local/share/gir-1.0/HarfBuzz-0.0.gir
is a symlink belonging to harfbuzz. You can unlink it:
  brew unlink harfbuzz

To force the link and overwrite all conflicting files:
  brew link --overwrite harfbuzz

To list all files that would be deleted:
  brew link --overwrite --dry-run harfbuzz
Warning: Refusing to link macOS provided/shadowed software: icu4c
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"
Linking /usr/local/Cellar/jpeg/9e... 18 symlinks created.
Warning: Refusing to link macOS provided/shadowed software: libffi
For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"
  export CPPFLAGS="-I/usr/local/opt/libffi/include"
Linking /usr/local/Cellar/libpng/1.6.37... 18 symlinks created.
Linking /usr/local/Cellar/libpthread-stubs/0.4... 1 symlinks created.
Linking /usr/local/Cellar/libspiro/20200505... 9 symlinks created.
Linking /usr/local/Cellar/libtiff/4.3.0... 94 symlinks created.
Linking /usr/local/Cellar/libtool/2.4.6_4... 20 symlinks created.
Linking /usr/local/Cellar/libuninameslist/20211114... 6 symlinks created.
Linking /usr/local/Cellar/libx11/1.7.3.1... 831 symlinks created.
Linking /usr/local/Cellar/libxau/1.0.9... 13 symlinks created.
Linking /usr/local/Cellar/libxcb/1.14_2... 2414 symlinks created.
Linking /usr/local/Cellar/libxdmcp/1.1.3... 4 symlinks created.
Linking /usr/local/Cellar/libxext/1.3.4... 65 symlinks created.
Linking /usr/local/Cellar/libxrender/0.9.10... 5 symlinks created.
Linking /usr/local/Cellar/lzo/2.10... 6 symlinks created.
Warning: Refusing to link macOS provided/shadowed software: m4
If you need to have m4 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/m4/bin:$PATH"' >> ~/.zshrc
Linking /usr/local/Cellar/mpdecimal/2.5.1... 11 symlinks created.
Linking /usr/local/Cellar/mysql@5.7/5.7.37... 87 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
Warning: Refusing to link macOS provided/shadowed software: openssl@1.1
If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
Linking /usr/local/Cellar/pango/1.50.5... 18 symlinks created.
Linking /usr/local/Cellar/pcre/8.45... 133 symlinks created.
Linking /usr/local/Cellar/pixman/0.40.0... 6 symlinks created.
Linking /usr/local/Cellar/pkg-config/0.29.2_3... 4 symlinks created.
Linking /usr/local/Cellar/postgresql@10/10.20_1... 167 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/postgresql@10/bin:$PATH"' >> ~/.zshrc
Linking /usr/local/Cellar/python@3.9/3.9.10... 3042 symlinks created.
Warning: Refusing to link macOS provided/shadowed software: readline
For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
Warning: Already linked: /usr/local/Cellar/ricty/4.1.1
To relink, run:
  brew unlink ricty && brew link ricty
Warning: Refusing to link macOS provided/shadowed software: sqlite
If you need to have sqlite first in your PATH, run:
  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.zshrc

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

For pkg-config to find sqlite you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"
Linking /usr/local/Cellar/xorgproto/2021.5... 11 symlinks created.
Linking /usr/local/Cellar/xz/5.2.5... 53 symlinks created.
Found a cask named "font-ricty-diminished" instead. Try
  brew uninstall --cask font-ricty-diminished

Error: No such keg: /usr/local/Cellar/font-ricty-diminished
```

なんか色々エラーが出たり、パスや環境変数を設定してね的なメッセージがでますが、リンクは張って貰えました。

```zsh
% ls -la /usr/local/opt
total 0
drwxrwxr-x  53 hoge  admin  1696  3 16 13:15 .
drwxr-xr-x  14 root     wheel   448  3 15 17:56 ..
-rw-r--r--   1 hoge  admin     0  3 13 12:25 .keepme
lrwxr-xr-x   1 hoge  admin    36  3 16 13:15 ca-certificates -> ../Cellar/ca-certificates/2022-02-01
lrwxr-xr-x   1 hoge  admin    24  3 16 13:15 cairo -> ../Cellar/cairo/1.16.0_5
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 fontconfig -> ../Cellar/fontconfig/2.13.1
lrwxr-xr-x   1 hoge  admin    28  3 16 13:15 fontforge -> ../Cellar/fontforge/20220308
lrwxr-xr-x   1 hoge  admin    25  3 16 13:15 freetype -> ../Cellar/freetype/2.11.1
lrwxr-xr-x   1 hoge  admin    25  3 16 13:15 freetype2 -> ../Cellar/freetype/2.11.1
lrwxr-xr-x   1 hoge  admin    24  3 16 13:15 fribidi -> ../Cellar/fribidi/1.0.11
lrwxr-xr-x   1 hoge  admin    19  3 16 13:15 gdbm -> ../Cellar/gdbm/1.23
lrwxr-xr-x   1 hoge  admin    22  3 16 13:15 gettext -> ../Cellar/gettext/0.21
lrwxr-xr-x   1 hoge  admin    22  3 16 13:15 giflib -> ../Cellar/giflib/5.2.1
lrwxr-xr-x   1 hoge  admin    21  3 16 13:15 glib -> ../Cellar/glib/2.70.4
lrwxr-xr-x   1 hoge  admin    40  3 16 13:15 gobject-introspection -> ../Cellar/gobject-introspection/1.70.0_3
lrwxr-xr-x   1 hoge  admin    26  3 16 13:15 graphite2 -> ../Cellar/graphite2/1.3.14
lrwxr-xr-x   1 hoge  admin    24  3 16 13:15 harfbuzz -> ../Cellar/harfbuzz/4.0.1
lrwxr-xr-x   1 hoge  admin    20  3 16 10:59 icu4c -> ../Cellar/icu4c/70.1
lrwxr-xr-x   1 hoge  admin    17  3 16 13:15 jpeg -> ../Cellar/jpeg/9e
lrwxr-xr-x   1 hoge  admin    17  3 16 13:15 libjpeg -> ../Cellar/jpeg/9e
lrwxr-xr-x   1 hoge  admin    17  3 16 13:15 libjpg -> ../Cellar/jpeg/9e
lrwxr-xr-x   1 hoge  admin    25  3 16 13:15 libmpdec -> ../Cellar/mpdecimal/2.5.1
lrwxr-xr-x   1 hoge  admin    23  3 16 13:15 libpng -> ../Cellar/libpng/1.6.37
lrwxr-xr-x   1 hoge  admin    30  3 16 13:15 libpthread-stubs -> ../Cellar/libpthread-stubs/0.4
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 libspiro -> ../Cellar/libspiro/20200505
lrwxr-xr-x   1 hoge  admin    23  3 16 13:15 libtiff -> ../Cellar/libtiff/4.3.0
lrwxr-xr-x   1 hoge  admin    25  3 16 13:15 libtool -> ../Cellar/libtool/2.4.6_4
lrwxr-xr-x   1 hoge  admin    34  3 16 13:15 libuninameslist -> ../Cellar/libuninameslist/20211114
lrwxr-xr-x   1 hoge  admin    24  3 16 13:15 libx11 -> ../Cellar/libx11/1.7.3.1
lrwxr-xr-x   1 hoge  admin    22  3 16 13:15 libxau -> ../Cellar/libxau/1.0.9
lrwxr-xr-x   1 hoge  admin    23  3 16 13:15 libxcb -> ../Cellar/libxcb/1.14_2
lrwxr-xr-x   1 hoge  admin    24  3 16 13:15 libxdmcp -> ../Cellar/libxdmcp/1.1.3
lrwxr-xr-x   1 hoge  admin    23  3 16 13:15 libxext -> ../Cellar/libxext/1.3.4
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 libxrender -> ../Cellar/libxrender/0.9.10
lrwxr-xr-x   1 hoge  admin    18  3 16 13:15 lzo -> ../Cellar/lzo/2.10
lrwxr-xr-x   1 hoge  admin    25  3 16 13:15 mpdecimal -> ../Cellar/mpdecimal/2.5.1
lrwxr-xr-x   1 hoge  admin    26  3 16 13:15 mysql@5.7 -> ../Cellar/mysql@5.7/5.7.37
lrwxr-xr-x   1 hoge  admin    28  3 16 09:27 openssl@1.1 -> ../Cellar/openssl@1.1/1.1.1m
lrwxr-xr-x   1 hoge  admin    22  3 16 13:15 pango -> ../Cellar/pango/1.50.5
lrwxr-xr-x   1 hoge  admin    19  3 16 13:15 pcre -> ../Cellar/pcre/8.45
lrwxr-xr-x   1 hoge  admin    19  3 16 13:15 pcre1 -> ../Cellar/pcre/8.45
lrwxr-xr-x   1 hoge  admin    23  3 16 13:15 pixman -> ../Cellar/pixman/0.40.0
lrwxr-xr-x   1 hoge  admin    29  3 16 13:15 pkg-config -> ../Cellar/pkg-config/0.29.2_3
lrwxr-xr-x   1 hoge  admin    29  3 16 13:15 pkgconfig -> ../Cellar/pkg-config/0.29.2_3
lrwxr-xr-x   1 hoge  admin    31  3 16 13:15 postgresql@10 -> ../Cellar/postgresql@10/10.20_1
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 python -> ../Cellar/python@3.9/3.9.10
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 python3 -> ../Cellar/python@3.9/3.9.10
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 python@3 -> ../Cellar/python@3.9/3.9.10
lrwxr-xr-x   1 hoge  admin    27  3 16 13:15 python@3.9 -> ../Cellar/python@3.9/3.9.10
lrwxr-xr-x   1 hoge  admin    24  3 16 10:50 readline -> ../Cellar/readline/8.1.2
lrwxr-xr-x   1 hoge  admin    21  3 16 11:36 ricty -> ../Cellar/ricty/4.1.1
lrwxr-xr-x   1 hoge  admin    26  3 16 13:15 xorgproto -> ../Cellar/xorgproto/2021.5
lrwxr-xr-x   1 hoge  admin    18  3 16 13:15 xz -> ../Cellar/xz/5.2.5
```