LoginSignup
1
1

More than 5 years have passed since last update.

OS Xでruby-installでRubyを入れる

Last updated at Posted at 2017-03-24

OS XでRubyをインストールする時にruby-installを使っているのですが、今Rubyをインストールしたら失敗したので、対応を書きます。Homebrewを使います。

環境

  • OS X El Capitan 10.11.6
  • ruby-install 0.6.1

エラー

単純に

% ruby-install ruby-2.3.3

とかやるとエラーになります。

(snip)
Undefined symbols for architecture x86_64:
  "_rb_ary_resize", referenced from:
      _ary_resize in resize.o
  "_rb_cArray", referenced from:
      _Init_resize in resize.o
  "_rb_define_method", referenced from:
      _Init_resize in resize.o
  "_rb_num2long", referenced from:
      _ary_resize in resize.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../../.ext/x86_64-darwin15/-test-/array/resize.bundle] Error 1
make[1]: *** [ext/-test-/array/resize/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.3.3 failed!

対応

まずOpenSSLを最新にします。

% brew upgrade openssl

使う時の各種パスを確認します。

% brew info openssl
(snip)
For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
(snip)

ruby-installに失敗してもソースは残ってるので移動します。

% cd ~/src/ruby-2.3.3

上のbrew infoで得た情報をもとに再度コンパイルします。

% make clean
% LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" ./configure --prefix=$HOME/.rubies/ruby-2.3.3
% make
% make install

これでruby-2.3.3がインストールできました。

% chruby
   ruby-2.2.3
   ruby-2.2.6
   ruby-2.3.3
1
1
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
1