RVM 経由で Ruby 2.0.0 をインストールできない

概要

RVM と一緒に Ruby 2.0.0 をインストールする必要があるレガシー コードベースを継承しました。私は Mac OS X Catalina を使用していますが、Ruby 2.0.0 のインストーラーが動作しません。

RVM 自体のインストールから Ruby 2.0.0 のインストールに至るまでの、私のインストール試行の様子を次に示します。

nbyrd$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.10.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.10/1.29.10.tar.gz.asc
gpg: Signature made Wed Mar 25 14:58:42 2020 PDT
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/Users/nbyrd/.rvm/archives/rvm-1.29.10.tgz'
Installing RVM to /Users/nbyrd/.rvm/
    RVM PATH line found in /Users/nbyrd/.mkshrc.
    RVM PATH line not found for Bash or Zsh, rerun this command with '--auto-dotfiles' flag to fix it.
    RVM sourcing line found in /Users/nbyrd/.profile /Users/nbyrd/.bash_profile /Users/nbyrd/.zlogin.
Installation of RVM in /Users/nbyrd/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/nbyrd/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.

👉  Donate: https://opencollective.com/rvm/donate


nbyrd$ source ~/.profile
nbyrd$ rvm autolibs enable
nbyrd$ rvm install 2.0.0 --force
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.0.0-p648.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Installing requirements for osx.
Updating system.......
Installing required packages: openssl.
Updating certificates bundle '/usr/local/etc/[email protected]/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/nbyrd/.rvm/rubies/ruby-2.0.0-p648, this may take a while depending on your cpu(s)...
ruby-2.0.0-p648 - #downloading ruby-2.0.0-p648, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.2M  100 10.2M    0     0  18.2M      0 --:--:-- --:--:-- --:--:-- 18.2M
ruby-2.0.0-p648 - #extracting ruby-2.0.0-p648 to /Users/nbyrd/.rvm/src/ruby-2.0.0-p648.....
ruby-2.0.0-p648 - #applying patch /Users/nbyrd/.rvm/patches/ruby/2.0.0/openssl3.patch.
ruby-2.0.0-p648 - #applying patch /Users/nbyrd/.rvm/patches/ruby/2.0.0/update-autoconf.patch.
ruby-2.0.0-p648 - #configuring.................................................
ruby-2.0.0-p648 - #post-configuration.
ruby-2.0.0-p648 - #compiling......................
Error running '__rvm_make -j8',
please read /Users/nbyrd/.rvm/log/1605305278_ruby-2.0.0-p648/make.log

There has been an error while running make. Halting the installation.

エラー メッセージで参照されている「make.log」ファイルの内容は次のとおりです。

[2020-11-13 14:09:14] __rvm_make
__rvm_make () 
{ 
    \make "$@" || return $?
}
current path: /Users/nbyrd/.rvm/src/ruby-2.0.0-p648
PATH=/usr/local/opt/coreutils/bin:/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/usr/local/sbin:/Users/nbyrd/.yarn/bin:/Users/nbyrd/.config/yarn/global/node_modules/.bin:/usr/local/sbin:/Users/nbyrd/.yarn/bin:/Users/nbyrd/.config/yarn/global/node_modules/.bin:/usr/local/sbin:/Users/nbyrd/.yarn/bin:/Users/nbyrd/.config/yarn/global/node_modules/.bin:/Users/nbyrd/.nvm/versions/node/v10.15.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/nbyrd/.rvm/bin
command(2): __rvm_make -j8
++ make -j8
    CC = /usr/bin/clang
    LD = ld
    LDSHARED = /usr/bin/clang -dynamiclib
    CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration   -fno-common -pipe 
    XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/[email protected]/include   -I. -I.ext/include/x86_64-darwin19.6.0 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/[email protected]/lib  -install_name /Users/nbyrd/.rvm/rubies/ruby-2.0.0-p648/lib/libruby.2.0.0.dylib -current_version 2.0.0 -compatibility_version 2.0.0  -fstack-protector -Wl,-u,_objc_msgSend  -fstack-protector -Wl,-u,_objc_msgSend  
    SOLIBS = 
compiling main.c
compiling dmydln.c
compiling dmyencoding.c
compiling version.c
compiling miniprelude.c
translating probes probes.d
compiling bignum.c
compiling class.c
. ./vm_opts.h
compiling compar.c
compiling complex.c
compiling dir.c
compiling dln_find.c
compiling enum.c
complex.c:79:1: warning: unused function 'f_cmp' [-Wunused-function]
f_cmp(VALUE x, VALUE y)
^
complex.c:109:1: warning: unused function 'f_lt_p' [-Wunused-function]
f_lt_p(VALUE x, VALUE y)
^
complex.c:116:1: warning: unused function 'f_mod' [-Wunused-function]
binop(mod, '%')
^
complex.c:30:21: note: expanded from macro 'binop'
inline static VALUE \
                    ^
<scratch space>:89:1: note: expanded from here
f_mod
^
complex.c:155:1: warning: unused function 'f_abs2' [-Wunused-function]
fun1(abs2)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:92:1: note: expanded from here
f_abs2
^
complex.c:157:1: warning: unused function 'f_conj' [-Wunused-function]
fun1(conj)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:96:1: note: expanded from here
f_conj
^
complex.c:159:1: warning: unused function 'f_floor' [-Wunused-function]
fun1(floor)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:100:1: note: expanded from here
f_floor
^
complex.c:160:1: warning: unused function 'f_imag' [-Wunused-function]
fun1(imag)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:102:1: note: expanded from here
f_imag
^
complex.c:164:1: warning: unused function 'f_real' [-Wunused-function]
fun1(real)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:110:1: note: expanded from here
f_real
^
complex.c:185:1: warning: unused function 'f_divmod' [-Wunused-function]
fun2(divmod)
^
complex.c:44:21: note: expanded from macro 'fun2'
inline static VALUE \
                    ^
<scratch space>:118:1: note: expanded from here
f_divmod
^
complex.c:197:1: warning: unused function 'f_idiv' [-Wunused-function]
fun2(idiv)
^
complex.c:44:21: note: expanded from macro 'fun2'
inline static VALUE \
                    ^
<scratch space>:124:1: note: expanded from here
f_idiv
^
complex.c:263:1: warning: unused function 'k_integer_p' [-Wunused-function]
k_integer_p(VALUE x)
^
complex.c:465:1: warning: unused function 'f_complex_new1' [-Wunused-function]
f_complex_new1(VALUE klass, VALUE x)
^
complex.c:547:1: warning: unused function 'm_sqrt_bang' [-Wunused-function]
imp1(sqrt)
^
complex.c:518:21: note: expanded from macro 'imp1'
inline static VALUE \
                    ^
<scratch space>:150:1: note: expanded from here
m_sqrt_bang
^
bignum.c:910:1: warning: unused function 'next_pow2' [-Wunused-function]
next_pow2(register unsigned long x)
^
compiling enumerator.c
compiling error.c
compiling eval.c
compiling load.c
compiling proc.c
compiling file.c
compiling gc.c
13 warnings generated.
compiling hash.c
compiling inits.c
compiling io.c
compiling marshal.c
compiling math.c
compiling node.c
compiling numeric.c
compiling object.c
compiling pack.c
compiling parse.c
compiling process.c
compiling random.c
compiling range.c
compiling rational.c
rational.c:86:1: warning: unused function 'f_gt_p' [-Wunused-function]
f_gt_p(VALUE x, VALUE y)
^
rational.c:136:1: warning: unused function 'f_floor' [-Wunused-function]
fun1(floor)
^
rational.c:40:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:93:1: note: expanded from here
f_floor
^
rational.c:157:1: warning: unused function 'f_truncate' [-Wunused-function]
fun1(truncate)
^
rational.c:40:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:103:1: note: expanded from here
f_truncate
^
rational.c:428:1: warning: unused function 'f_rational_new_bang2' [-Wunused-function]
f_rational_new_bang2(VALUE klass, VALUE x, VALUE y)
^
rational.c:537:1: warning: unused function 'f_rational_new1' [-Wunused-function]
f_rational_new1(VALUE klass, VALUE x)
^
rational.c:552:1: warning: unused function 'f_rational_new_no_reduce1' [-Wunused-function]
f_rational_new_no_reduce1(VALUE klass, VALUE x)
^
1 warning generated.
compiling re.c
compiling regcomp.c
compiling regenc.c
compiling regerror.c
compiling regexec.c
compiling regparse.c
compiling regsyntax.c
compiling ruby.c
6 warnings generated.
compiling safe.c
compiling signal.c
compiling sprintf.c
compiling st.c
compiling strftime.c
compiling string.c
compiling struct.c
compiling time.c
compiling transcode.c
compiling util.c
compiling variable.c
compiling compile.c
compiling debug.c
compiling iseq.c
compiling vm.c
compiling vm_dump.c
compiling vm_backtrace.c
compiling vm_trace.c
compiling thread.c
vm.c:1916:31: warning: expression does not compute the number of elements in this array; element type is 'int', not 'VALUE' (aka 'unsigned long') [-Wsizeof-array-div]
                                 sizeof(th->machine_regs) / sizeof(VALUE));
                                        ~~~~~~~~~~~~~~~~  ^
vm.c:1916:31: note: place parentheses around the 'sizeof(VALUE)' expression to silence this warning
thread.c:977:27: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
        tp->tv_usec = ts.tv_nsec / 1000;
                    ~ ~~~~~~~~~~~^~~~~~
thread.c:4835:20: error: implicit declaration of function 'rb_frame_last_func' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    const ID mid = rb_frame_last_func();
                   ^
thread.c:4835:20: note: did you mean 'rb_frame_this_func'?
./include/ruby/intern.h:369:4: note: 'rb_frame_this_func' declared here
ID rb_frame_this_func(void);
   ^
1 warning and 1 error generated.
make: *** [thread.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.
++ return 2

このエラーを回避するために何ができるか本当にわかりません。これまで Ruby を使ったことがありませんでしたが、ソース コードに関数宣言 (「rb_frame_last_func」) のない関数呼び出しがあるようです。

複数の C コンパイラを試しましたが、どれも機能しませんでした。 RVM 開発者にも助けを求めてみましたが、彼らは私の質問にまったく答えてくれませんでした。 RVM の Web サイトには、これらのエラーに関する詳細が記載されていません。そして私は Stackoverflow や Google を閲覧し、数十の代替アプローチを試しましたが、どれもうまくいきませんでした。

誰かが私にここで何が欠けているのか教えてもらえますか?

解決策

これは、Xcode 12 に含まれるツールの動作の変更によるものです。

https://translate.google.com/translate?hl=ja&sl=en&tl=ja&u=https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes

おそらく、コンパイル フラグを環境内で設定して RVM に渡したいと思うでしょう。

export optflags="-Wno-error=implicit-function-declaration"

その後、再試行できます。

$ rvm install 2.0.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.0.0-p648.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Installing requirements for osx.
Updating system - please wait
Installing required packages: openssl - please wait
Certificates bundle '/usr/local/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/foo/.rvm/rubies/ruby-2.0.0-p648, this may take a while depending on your cpu(s)...
ruby-2.0.0-p648 - #downloading ruby-2.0.0-p648, this may take a while depending on your connection...
ruby-2.0.0-p648 - #extracting ruby-2.0.0-p648 to /Users/foo/.rvm/src/ruby-2.0.0-p648 - please wait
ruby-2.0.0-p648 - #applying patch /Users/foo/.rvm/patches/ruby/2.0.0/openssl3.patch - please wait
ruby-2.0.0-p648 - #applying patch /Users/foo/.rvm/patches/ruby/2.0.0/update-autoconf.patch - please wait
ruby-2.0.0-p648 - #configuring - please wait
ruby-2.0.0-p648 - #post-configuration - please wait
ruby-2.0.0-p648 - #compiling - please wait
ruby-2.0.0-p648 - #installing - please wait
ruby-2.0.0-p648 - #making binaries executable - please wait
ruby-2.0.0-p648 - #downloading rubygems-3.0.8
ruby-2.0.0-p648 - #extracting rubygems-3.0.8 - please wait
ruby-2.0.0-p648 - #removing old rubygems - please wait
ruby-2.0.0-p648 - #installing rubygems-3.0.8 - please wait
Error running 'env GEM_HOME=/Users/foo/.rvm/gems/ruby-2.0.0-p648@global GEM_PATH= /Users/foo/.rvm/rubies/ruby-2.0.0-p648/bin/ruby -d /Users/foo/.rvm/src/rubygems-3.0.8/setup.rb --no-document',
please read /Users/foo/.rvm/log/1605308161_ruby-2.0.0-p648/rubygems.install.log

最後にエラーが発生したにもかかわらず、Ruby は正常にコンパイルおよびインストールされます。

$ rvm list
   ruby-2.0.0-p648 [ x86_64 ]
   ruby-2.5.7 [ x86_64 ]
=* ruby-2.7.1 [ x86_64 ]
   ruby-3.0.0-preview1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
$ rvm use 2.0.0
rvm use 2.0.0
Using /Users/foo/.rvm/gems/ruby-2.0.0-p648
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin19.6.0]

おそらくネイティブ拡張機能を備えた gem にも同じ修正が必要です。

gem install some_gem_name --with-cflags="-Wno-error=implicit-function-declaration"

または、バンドラーを使用するアプリの場合:

bundle config build.some_gem_name --with-cflags=\"-Wno-error=implicit-function-declaration\"