> For the complete documentation index, see [llms.txt](https://hayashier.gitbook.io/article/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hayashier.gitbook.io/article/others/terminal-not-launch.md).

# Macでターミナルが開かない (zsh編)

## Macでターミナルが開かない (zsh編)

厳密にはターミナルを開いても即終了してしまう事象に遭遇しました。

画面上部から、Terminal -> Preferencesを選択し、Generalの項目を選択すると、Shell open withという項目があり、Command (complete path)\
でデフォルトで起動するシェルを指定しますが、`/usr/local/bin/zsh`から`/bin/bash`に変更して起動して一度ターミナルを起動します。

その後、コマンドとして`/usr/local/bin/zsh`を実行すると以下のエラーが確認できました。

```
dyld: Library not loaded: /usr/local/opt/gdbm/lib/libgdbm.4.dylib
  Referenced from: /usr/local/bin/zsh
  Reason: image not found
Abort trap: 6
```

以下のようにzshを再インストールして、デフォルトで起動するシェルをzshに戻して解消しました。

```
$ brew reinstall zsh && brew unlink zsh && brew link zsh
```

なお、zshを再インストールする前に、エラー文に記載のGDBMを再インストールしましたが、特に解消されませんでした。

```
$ brew reinstall gdbm
```

* References
  * [teminalが動かなくなってしまいました](https://umegusa.hatenablog.jp/entry/2012/07/21/155637)
  * [【Zshが動かない】dyld: Library not loaded: /usr/local/opt/gdbm/lib/libgdbm.4.dylibが出た時の対処【iTerm2が動かない】](https://blogenist.jp/2018/07/07/4966/#Zsh)
  * [macOSのアップデートを見越して標準のスクリプトランタイムに依存せずHomeBrewが手軽に入るか検証してみた](https://dev.classmethod.jp/articles/homebrew-install-without-default-script-language-runtime/)
