MacでRuby入門 ~pryが起動しない~

pryがとても便利だと聞いたので、使ってみようと思い、インストールを試みた。

$ gem install pry pry-doc

Fetching: coderay-1.1.0.gem (100%)
Successfully installed coderay-1.1.0
Fetching: slop-3.6.0.gem (100%)
Successfully installed slop-3.6.0
Fetching: method_source-0.8.2.gem (100%)
Successfully installed method_source-0.8.2
Fetching: pry-0.10.1.gem (100%)
Successfully installed pry-0.10.1
invalid options: -SNw2
(invalid options are ignored)
Parsing documentation for coderay-1.1.0
Installing ri documentation for coderay-1.1.0
Parsing documentation for method_source-0.8.2
Installing ri documentation for method_source-0.8.2
Parsing documentation for pry-0.10.1
Installing ri documentation for pry-0.10.1
Parsing documentation for slop-3.6.0
Installing ri documentation for slop-3.6.0
Done installing documentation for coderay, method_source, pry, slop after 5 seconds
Fetching: yard-0.8.7.4.gem (100%)
Successfully installed yard-0.8.7.4
Fetching: pry-doc-0.6.0.gem (100%)
Successfully installed pry-doc-0.6.0
Parsing documentation for pry-doc-0.6.0
Installing ri documentation for pry-doc-0.6.0
Parsing documentation for yard-0.8.7.4
Installing ri documentation for yard-0.8.7.4
Done installing documentation for pry-doc, yard after 4 seconds
6 gems installed

特にエラーも出ていないので、とりあえず、pryのバージョンを確認してみる

$ pry -v

-bash: pry: command not found

あれ?コマンドが見つからない

$ pry

-bash: pry: command not found

、、、やはり無理か

原因がわからないので、調べてみた。
どうも、rbenvというrubyのパッケージマネージャを使用していると、gemでインストールしたコマンドを使う前にrbenv rehashをして $HOME/.rvm/shims 以下の情報を更新する必要があるらしい。

というわけで

$ rbenv rehash

して、再び

$ pry -v

Pry version 0.10.1 on Ruby 2.1.2

お、無事、バージョンが表示された。 そして、pryを実行

$ pry

[1] pry(main)>

無事、pryが起動しました。