> 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/development/pyenv-no-such-file-error.md).

# /usr/local/Cellar/pyenv/1.2.21/libexec/pyenv: No such file or directoryのエラーの対処方法

## /usr/local/Cellar/pyenv/1.2.21/libexec/pyenv: No such file or directoryのエラーの対処方法

Pythonに依存のコマンド実行時に、以下のようなエラーが出力されるようになりました。

```
$ aws --version                                                                                                      
/Users/hayashier/.pyenv/shims/aws: line 21: /usr/local/Cellar/pyenv/1.2.21/libexec/pyenv: No such file or directory
```

`brew upgrade`でコマンド実行時に、pyenvのバージョンが上がったことに起因しており、ファイルパスの変更があったことによるもののようです。そのため、以下のコマンドを実行することで事象が解消されました。

```
$ pyenv rehash
```

正常にコマンドが実行できるようになったことが確認できます。

```
$ aws --version
aws-cli/1.19.1 Python/3.9.0 Darwin/19.6.0 botocore/1.20.78
```

* References
  * [RFE: pyenv update should regenerate shims unconditionally #1068](https://github.com/pyenv/pyenv/issues/1068)
  * [pyenvをアップデートしたらlibexec/pyenv: No such file or directoryとか言われた話](https://e-tec-memo.herokuapp.com/article/233/)
