テクめも

プログラミング関連のちょっとしたTipsなどを書いています。

pyenvのanacondaを使っているときgit stashのエラーを解決する

前提

  • pyenvでanacondaをインストールしている
    • anacondaをインストールしていない場合、問題は発生しない
  • インストールしたanacondaをpyenv globalなどで設定していない

つまり、以下のような状況です。

$ pyenv versions
  system
* 3.6.8 (set by /Users/username/.pyenv/version)
  3.7.2
  anaconda3-5.3.0

問題

  • git stashを使うときにエラーが発生する
    • 他のgitコマンドではエラーが発生しない
$ git stash
pyenv: gettext.sh: command not found

The `gettext.sh' command exists in these Python versions:
  anaconda3-5.3.0

/usr/local/Cellar/git/2.20.1/libexec/git-core/git-sh-setup: line 93: eval_gettext: command not found
/usr/local/Cellar/git/2.20.1/libexec/git-core/git-stash: line 658: eval_gettext: command not found

原因

anacondaのインストールによって、gettextのパスがpyenvのanacondaによって上書きされており、また、上書きされているにもかかわらず、anacondaのバージョンをpyenvで設定していないので、パスが通っていないことが原因と思われます。

解決策

gettextのパスの設定します。パスはmacの例です。

export PATH="/usr/local/opt/gettext/bin:$PATH"

gettextがない場合、brewでインストールできます。

brew install gettext