0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pyenv rehash lock エラー(.pyenv-shim)

0
Posted at

発生ケース

エディター起動時の terminal に表示される。

ログ

pyenv: cannot rehash: couldn't acquire lock /Users/username/.pyenv/shims/.pyenv-shim for 60 seconds. Last error message:
/opt/homebrew/Cellar/pyenv/2.6.23/libexec/pyenv-rehash: 行 22: /Users/username/.pyenv/shims/.pyenv-shim: cannot overwrite existing file
pyenv: cannot rehash: couldn't acquire lock /Users/username/.pyenv/shims/.pyenv-shim for 60 seconds. Last error message:
/opt/homebrew/Cellar/pyenv/2.6.23/libexec/pyenv-rehash: 行 22: /Users/username/.pyenv/shims/.pyenv-shim: cannot overwrite existing file

原因

  • pyenv の rehash は /Users/username/.pyenv/shims/.pyenv-shim を一時的なロックファイルとして使う
  • シェル起動時に .zprofile の pyenv init --path と .zshrc の pyenv init - が rehash を走らせる
  • .pyenv-shim(前回の rehash が中断され、正常終了時の削除が行われなかったもの)が邪魔をし、新しい rehash がロックを取れなかった
  • cannot overwrite existing file は「noclobber で空ファイルを作ろうとしたが、既にファイルが存在する」という意味
  • エディターが複数ターミナルを同時起動するため、同じエラーが2回出ていた

対応

  1. 古いロックファイルを削除: rm -f ~/.pyenv/shims/.pyenv-shim
  2. pyenv rehash を実行して正常完了を確認

再発時の対処

同じエラーが出た場合は、以下を実行する。
rm -f ~/.pyenv/shims/.pyenv-shim && pyenv rehash
これでエラーは出なくなるはず。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?