LoginSignup
0
0

More than 5 years have passed since last update.

fishの$PATHにいらんのが付いてるのを消す

Last updated at Posted at 2018-04-19

概要

osxにfish入れてたんですが,anacondaを新規にいれてpathを変えようと思ってツボにはまった.

結論

~/.config/fish/にあるfishd.****を消した.

anaconda3の...

ちょっとずれるのですが,メモがわりに.
anaconda3のmac版を入れると,user環境にいれられない場合があります.(謎)
その場合は,'/'にuser権限で作ります.まあなんと強引な...これをfishのpathに通そうとしたのが,事の始まりでした.

症状

> head ~/.config/fish/config.fish
set PATH ~/.rbenv/versions/2.4.3/bin ~/anaconda3/bin ~/.rbenv/shims /usr/local/bin /usr/bin $PATH /sbin /usr/sbin . ~/bin

などとしているのですが,

> echo $PATH
/Users/bob/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/bin 
/Users/bob/.rbenv/versions/2.4.3/bin /Users/bob/anaconda3/bin 
/Users/bob/.rbenv/shims /usr/local/bin /usr/bin . 
/Users/bob/.rbenv/shims /Users/bob/.rbenv/versions/2.4.3/bin 
/Users/bob/anaconda3/bin /Users/bob/bin /sbin /usr/bin /usr/local/bin 
/usr/local/opt/tcl-tk/bin /usr/sbin /bin /opt/X11/bin 
/Library/TeX/texbin /sbin /usr/sbin . /Users/bob/bin

するとここでせっていしているより前に余計な(昔設定していた)pathがたくさん出てきて,これがいくらやってもきえんかった.

最初の対応

$fish_user_pathsの中に入っていて,

> echo $fish_user_paths 
. /Users/bob/.rbenv/shims /Users/bob/.rbenv/versions/2.4.3/bin /Users/bob/anaconda3/bin /Users/bob/bin /sbin /usr/bin /usr/local/bin /usr/local/opt/tcl-tk/bin /usr/sbin

これは

set -e fish_user_paths[0..-1]

で消えます.それでも残ってる場合は,fishdを消してください.
ないと自動的に生成するようですが,怖い場合は適当にcpとかね.

osx固有の問題?

osxでは

/etc/profile

が起動されるそうで, /usr/libexec/path_helperで,

> cat /etc/paths.d/*
/opt/X11/bin
/Library/TeX/texbin


/Applications/TeXLive/Library/texlive/2013/bin/universal-darwin
/Applications/TeXLive/Library/mactexaddons/bin

> cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

なんかから基本となるのができるようです.

そこにfishが上書きしていくようですが,ちょっと不整合あり.

さらに,fishd.****で

SET GEMPATH:/Users/bob/\x2erbenv/versions/2\x2e4\x2e3/lib/ruby/ge\
ms/2\x2e4\x2e0/bin

が追加されています.うううん.これは??

ruby gemsの謎...

これも少しずれるのですが...
ruby gemsでinstall dirをどこにするかで
みなさん悩まれます.gem envするとかで解決しますが,
gemのインストール先にrbenvが指すものとGem.user_dirがあることを知らなくてハマった話 at hatena blog
がいい感じにまとめてくれてます.

でも,悩んだのは,
EXECUTABLE DIRECTORY
です.gem env ***で出てくるかと思ったのですが,
http://guides.rubygems.org/faqs/#user-install
あるいは
http://docs.seattlerb.org/rubygems/
ここにあるrdocから
http://docs.seattlerb.org/rubygems/Gem/Commands/EnvironmentCommand.html
へ行ってsourceを見ると選べるoptionsがわかるが,そこにもありません.どこやね...

で,ありました.

class Gem::Commands::SetupCommand

のgenerate_default_dirs(install_destdir)の
中に.

bin_dir = RbConfig::CONFIG['bindir']

そうだよね.gemsではなくてrubyのbinだものね...

RbConfig.expand("$(bindir)")

で出てくることが判明.なんやrubyの標準moduleやんか.
結局sourceを読めばわかるという,rubyでよくある話.

でも,fishはそれをどこでやってる?
fish shellでrbenvを使う at Qiita
が良いようで.

omf install rbenv

でなんか動くようになった.調べる必要あり.

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