LoginSignup
3
3

More than 5 years have passed since last update.

CygwinにRubyのpryをインストールする。

Last updated at Posted at 2016-11-18

irbよりも強力だとされるpryだがインストールが面倒くさかったので、備忘録としてここに記述します。

前準備

setup-x86_64.exe
にて libreadline-devel: GNU readline and history libraries(development)
をインストールしておく。
pryの実行にはReadlineが必須であるため。

Ruby 2.3.3 のコンパイルとインストール

Cygwinには元から
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-cygwin]
がインストールされているが、
https://www.ruby-lang.org/ja/
から最新(2016-12-18時点)のソースコードruby-2.3.3.tar.gz
を持ってきてインストールする。

./configure --with-readline
make
make install

pryのインストール

$ gem install pry pry-doc
ERROR:  Loading command: install (Fiddle::DLError)
       can't load kernel32
ERROR:  While executing gem ... (NoMethodError)
   undefined method `invoke_with_build_args' for nil:NilClass

エラーが出るので以下のファイル
/usr/local/lib/ruby/2.3.0/win32/resolv.rb

dlload "kernel32"
の部分をを以下のように書き換える(ここが一番のはまりポイント)
dlload "kernel32.dll"
もう一度 (Ruby 2.4.0ではこの部分が修正されているので必要なし)

$ gem install pry pry-doc

gemの実行でopensslのエラーが発生する場合

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

httpsからhttpに変更してしまうのが楽:sweat_smile:

$ gem source -r https://rubygems.org/
$ gem source -a http://rubygems.org/
https://rubygems.org is recommended for security over http://rubygems.org/

Do you want to add this insecure source? [yn]  yと入力
http://rubygems.org/ added to sources

以上

3
3
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
3
3