OS の状況
$ cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"
ビルド失敗時の状況
- エラーログの末尾はこんな感じ
making dummy probes.h
compiling ast.c
In file included from vm_core.h:164:0,
from iseq.h:14,
from mini_builtin.c:3,
from miniinit.c:51:
thread_pthread.h:109:39: エラー: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
^
In file included from iseq.h:14:0,
from mini_builtin.c:3,
from miniinit.c:51:
vm_core.h: 関数 ‘rb_current_execution_context’ 内:
vm_core.h:1860:34: エラー: ‘ruby_current_ec’ が宣言されていません (この関数内での最初の使用)
rb_execution_context_t *ec = ruby_current_ec;
^
vm_core.h:1860:34: 備考: 未宣言の識別子は出現した各関数内で一回のみ報告されます
miniinit.c: トップレベル:
cc1: 警告: 認識できないコマンドラインオプション "-Wno-tautological-compare" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-self-assign" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-parentheses-equality" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-constant-logical-operand" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-cast-function-type" です [デフォルトで有効]
make: *** [miniinit.o] エラー 1
make: *** 未完了のジョブを待っています....
In file included from vm_core.h:164:0,
from iseq.h:14,
from ast.c:6:
thread_pthread.h:109:39: エラー: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
^
In file included from iseq.h:14:0,
from ast.c:6:
vm_core.h: 関数 ‘rb_current_execution_context’ 内:
vm_core.h:1860:34: エラー: ‘ruby_current_ec’ が宣言されていません (この関数内での最初の使用)
rb_execution_context_t *ec = ruby_current_ec;
^
vm_core.h:1860:34: 備考: 未宣言の識別子は出現した各関数内で一回のみ報告されます
ast.c: トップレベル:
cc1: 警告: 認識できないコマンドラインオプション "-Wno-tautological-compare" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-self-assign" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-parentheses-equality" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-constant-logical-operand" です [デフォルトで有効]
cc1: 警告: 認識できないコマンドラインオプション "-Wno-cast-function-type" です [デフォルトで有効]
make: *** [ast.o] エラー 1
external command failed with status 2
結論
gcc のバージョンを上げる。
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-8
$ scl enable devtoolset-8 bash
$ rbenv install 3.3.4
==> Downloading ruby-3.3.4.tar.gz...
-> curl -q -fL -o ruby-3.3.4.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.4.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.0M 100 21.0M 0 0 10.1M 0 0:00:02 0:00:02 --:--:-- 10.1M
==> Installing ruby-3.3.4...
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.4" --enable-shared --with-ext=openssl,psych,+
-> make -j 2
-> make install
==> Installed ruby-3.3.4 to /home/deploy_user/.rbenv/versions/3.3.4
補足
yumのリポジトリのリンクがことごとく 404 になってしまっている場合には、こちら を参照するといいかもしれませんscl enable devtoolset-8 bashを永続的に設定したい場合には、~/.bashrcにsource scl_source enable devtoolset-8と書きます