LoginSignup
15
8

More than 3 years have passed since last update.

Avoid warning of 'brew doctor' with fish & pyenv

Last updated at Posted at 2017-06-05

tl;dr

Just add following function to ~/.config/fish/config.fish

function brew
    set -xl PATH $PATH # Protect global PATH by local PATH
    if type -q pyenv; and contains (pyenv root)/shims $PATH
        set -e PATH[(contains -i (pyenv root)/shims $PATH)]
    end

    command brew $argv
end

説明

pyenvをインストールした後、brew doctorを実行すると警告が出るようになります。詳しくはpyenvのリポジトリのissueを参考のこと。

当該issueによれば、解決方法の一つとして、.bashrc

alias brew="env PATH=${PATH//$(pyenv root)\/shims:/} brew"

と書くなどがあります。が、これはあくまでbashでの話。シェルにfishを使うとそうもいきません。

そこで最初に書いた通り、brewコマンドを上書きするfunctionをfishの設定ファイルに定義することでとりあえず解決しました。

もし他にもっと良い方法があればコメントしてくださると助かります。

15
8
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
15
8