LoginSignup
8
2

More than 3 years have passed since last update.

fish 3.1.0 iTerm起動時にエラーが出る

Last updated at Posted at 2020-04-26

fish 3.1.0 iTerm起動時にエラーが出る

問題

iTermを再起動した所、以下のエラーが出てきた。

~/.config/fish/config.fish (line 1):
rbenv init - | source
^
in command substitution
    called on line 36 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
~/.config/fish/config.fish: Unknown error while evaluating command substitution
from sourcing file ~/.config/fish/config.fish
    called during startup

おそらく、~/.config/fish/config.fishで設定している eval (rbenv init - | source) のところでエラーが出ている。

下記は原因がわかった上で実行しているが、whichを実行しても何も返ってこない。

$ which fish
# 期待結果 /usr/local/bin/fish

解決策1

~/.config/fish/config.fish の最初に、パスを追加する。

set PATH /usr/local/bin $PATH

追加する理由としては、パスを確認した時に上記のものが入っていないから。

$ echo $PATH
/usr/bin /bin /usr/sbin /sbin

しかしながら、これはやや強引な気もするのでよくないかも。

解決策2

iTermの環境設定を修正する。
iTerm > Preferences > Profiles > General > Commond に、Commondで/usr/local/bin/fishを設定している。これを、

/usr/local/bin/fish -l

に変更する。設定したらiTermを再起動する。

ちゃんと which も返ってくるようになるよ。echoの結果もちゃんとしてる。

$ echo $PATH
/Users/{ユーザ名}/.rbenv/shims /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/share/dotnet ~/.dotnet/tools

ちなみに -l オプションは「ログインシェルとして起動する」と言う意味。他のオプションなど気になる人は公式で。

参考:fish - the friendly interactive shell — fish-shell 3.1.0 documentation

解決策1よりこちらの方がいいかもしれない。

原因

前日にHomebrewでインストールしたものをupdateしたせいかもしれない。その時に、fishのバージョンが3.1.0に上がったと思われる。
fish の3.1.0は2020/2/12にリリースされていた。詳しくはリリースノートからどうぞ。

いつから-lオプションが必要になったかは、issueのコメントを読むとどうやら、3.1.0になってからのようだ。Fish v3.0.2では、ログインシェルであるかに違いはみられないが、Fish v3.1.0では /usr/local/bin をはじめとして他のPATHも差があるみたい。

参考:fish 3.1.0 does not include /usr/local/bin in the PATH · Issue #6594 · fish-shell/fish-shell

余談

雑に下のエラー文で検索したら

~/.config/fish/config.fish: Unknown error while evaluating command substitution from sourcing file ~/.config/fish/config.fish

ヒットした記事がこちら。

RubyMineのターミナルが壊れた話 - @ledsun blog

同じところでエラーが出てて、ほんとにありがてえ…。

参考

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