Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away