Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Fix vm_core.h Error Ruby_current_ec Undeclared When Install Ruby 3.1.3 or 3.0.5

Permalink

Please notice below method is outdated and ruby core team confirm it’s a bug

Today ruby core team release the 3.1.3 and 3.0.5 patch version, but when I install it on CentOS 7, I got the below errors:

make: *** [miniinit.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from vm_core.h:83:0,
from iseq.h:14,
from ast.c:6:
thread_pthread.h:108:43: error: 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: In function ‘rb_current_execution_context’:
vm_core.h:1870:34: error: ‘ruby_current_ec’ undeclared (first use in this function)
rb_execution_context_t *ec = ruby_current_ec;
^
vm_core.h:1870:34: note: each undeclared identifier is reported only once for each function it appears in
ast.c: At top level:
cc1: warning: unrecognized command line option "-Wno-tautological-compare" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-self-assign" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-cast-function-type" [enabled by default]
make: *** [ast.o] Error 1

After do some research, I found it works in AWS linux (gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-15)) and Ubuntu (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0) smoothly, but CentOS 7 will always failed. (gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44))

So I guess probably it’s relative with the old stock gcc version of CentOS 7, luckily new gcc can be installed in CentOS 7 easily.

yum list | grep gcc
yum install centos-release-scl-rh
yum install llvm-toolset-7-clang
yum install centos-release-scl
yum install devtoolset-7-gcc.x86_64 && yum install devtoolset-7-gcc-c++.x86_64
# or yum install devtoolset-7-toolchain
scl enable devtoolset-7 bash
rbenv install 3.1.3 # now can successully install ruby!

Hoping this article can save you at least half day time and having a nice day!

Comments