1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

home brewを使ってインストールしたdocker-syncにfishでpathを通す

1
Last updated at Posted at 2019-08-31

パスの通し方

今までRubyのインストールにはrbenvを使ってたんですが、最近はDockerを使ってるので、MacBookの新調をきっかけにrbenvをやめて、homebrewでシステムインストールしました。homebrewでインストールしたRubyを使うには、Rubygemそれぞれに対してパスを通してあげないといけないみたいです。
僕はfishを使ってるのでこんな感じです。

~/.config/fish/config.fish
set PATH /usr/local/lib/ruby/gems/2.6.0/bin /usr/local/opt/ruby/bin $PATH

bashの人はこんな感じでしょうか。

~/.bashrc
export PATH=$PATH:/usr/local/lib/ruby/gems/2.6.0/bin:/usr/local/opt/ruby/bin 
  • /usr/local/opt/ruby/bin
    • Rubyのパス
  • /usr/local/lib/ruby/gems/2.6.0/bin
    • gemのパス

です。

詳細

homebrewでシステムインストールすると言っても、homebrewをインストールするとMacデフォルトのRubyとは別にRubyがインストールされるみたいです。

Terminal
><((("> brew install ruby
Warning: ruby 2.6.3 is already installed and up-to-date

まずハマったのがここなんですが、Rubyのバージョンを確認するとhomebrewでインストールしたものとは異なりました。

Terminal
><((("> ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
><((("> which ruby
/usr/bin/ruby

このままではデフォルトのRuby を参照しているのでパスを通してあげないといけないみたいです。

~/.config/fish/config.fish
set PATH /usr/local/opt/ruby/bin
Terminal
><((("> source ~/.config/fish/config.fish
><((("> ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

一件落着かと思いきや、確かにインストールしたはずのdocker-syncに対してもパスが通ってません。

Terminal
><((("> gem install docker-sync
Successfully installed docker-sync-0.5.11
Parsing documentation for docker-sync-0.5.11
Done installing documentation for docker-sync after 0 seconds
1 gem installed
><((("> docker-sync start
fish: Unknown command docker-sync

gemgemでパスを通してあげないといけないみたいですね。

~/.config/fish/config.fish
set PATH /usr/local/lib/ruby/gems/2.6.0/bin /usr/local/opt/ruby/bin

これで本当に解決です。

余談

なんとなく、ほんの1年前まで「パスを通す」の意味もわからなかったことを思い出しました。
こんな記事でも誰かの参考になればいいなと思います。
もしわからないことあったらコメントとかで聞いてください。
間違いとかも指摘してもらえたらと思います。

それにしてもカスタマイズに時間が取られすぎてやりたいことに手がつけられません。。。

参考

StackOverflow

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?