# 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/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hayashier.gitbook.io/article/others/terminal-not-launch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
