mysql2
mysql2 copied to clipboard
Unable to build on Centos 6 and ruby 2.7
Hello,
I have been fighting with this for a while now and I am at a loss. For whatever reason the plugin refuses to build on never versions of ruby on our system.
# /opt/chef/embedded/bin/gem install mysql2 -q --no-document -v "0.5.3" --source=https://rubygems.org
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/mysql2-0.5.3/ext/mysql2
/opt/chef/embedded/bin/ruby -I /opt/chef/embedded/lib/ruby/2.7.0 -r ./siteconf20210128-20062-1y53m9f.rb extconf.rb
checking for rb_absint_size()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/$(RUBY_BASE_NAME)
/opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:482:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:575:in `try_link0'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:593:in `try_link'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:805:in `try_func'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:1094:in `block in have_func'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:982:in `block in checking_for'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:981:in `checking_for'
from /opt/chef/embedded/lib/ruby/2.7.0/mkmf.rb:1093:in `have_func'
from extconf.rb:25:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/opt/chef/embedded/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/mysql2-0.5.3/mkmf.log
extconf failed, exit code 1
The core issue is that it is unable to include stdalign.h (from mkmf.log)
In file included from /opt/chef/embedded/include/ruby-2.7.0/ruby/ruby.h:29,
from /opt/chef/embedded/include/ruby-2.7.0/ruby.h:33,
from conftest.c:1:
/opt/chef/embedded/include/ruby-2.7.0/ruby/defines.h:157:23: error: stdalign.h: No such file or directory
In file included from /opt/chef/embedded/include/ruby-2.7.0/ruby.h:33,
from conftest.c:1:
This file is not present in gcc 4.4.7 which is the latest available. But the strange thing is that the gcc version does not change between the ruby versions.
This is the output of the RbConfig on 2.3
# /opt/chef/embedded/bin/ruby -r pp -e 'pp RbConfig::CONFIG.select { |k,v| k =~ /^C/ }'
{"CONFIGURE"=>"configure",
"COMMON_HEADERS"=>"",
"COMMON_MACROS"=>"",
"COMMON_LIBS"=>"",
"CROSS_COMPILING"=>"no",
"CCDLFLAGS"=>"-fPIC",
"CHDIR"=>"cd -P",
"CP"=>"cp",
"CC_VERSION"=>"gcc -v",
"COUTFLAG"=>"-o ",
"CPPOUTFILE"=>"-o conftest.i",
"CPP"=>"gcc -E",
"CXXFLAGS"=>"-I/opt/chef/embedded/include -O2 -O3 -g -pipe",
"CPPFLAGS"=>
"-I/opt/chef/embedded/include -O2 -O3 -g -pipe -I/opt/chef/embedded/include ",
"CFLAGS"=>"-I/opt/chef/embedded/include -O2 -O3 -g -pipe -fPIC",
"CXX"=>"g++",
"CC"=>"gcc"}
This is the same on 2.7
/opt/chef/embedded/bin/ruby -r pp -e 'pp RbConfig::CONFIG.select { |k,v| k =~ /^C/ }'
{"CC_WRAPPER"=>"",
"CONFIGURE"=>"configure",
"COMMON_HEADERS"=>"",
"COMMON_MACROS"=>"",
"COMMON_LIBS"=>"",
"CROSS_COMPILING"=>"no",
"CCDLFLAGS"=>"-fPIC",
"CHDIR"=>"cd -P",
"CP"=>"cp",
"CC_VERSION_MESSAGE"=>
"gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)\n" +
"Copyright (C) 2017 Free Software Foundation, Inc.\n" +
"This is free software; see the source for copying conditions. There is NO\n" +
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.",
"CC_VERSION"=>"gcc --version",
"CSRCFLAG"=>"",
"COUTFLAG"=>"-o ",
"CPPOUTFILE"=>"-o conftest.i",
"CPP"=>"gcc -E",
"CXXFLAGS"=> "-I/opt/chef/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -O3 -g -pipe",
"CXX"=>"g++",
"CPPFLAGS"=> "-I/opt/chef/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -O3 -g -pipe -I/opt/chef/embedded/include ",
"CFLAGS"=> "-I/opt/chef/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -O3 -g -pipe -fPIC",
"CC"=>"gcc"}
What perplexes me here is the gcc 7.3.1, is that the version ruby was build with? That would explain the expected library that is there.
Any hints what I might be doing wrong? Or do we need to ditch Centos 6 for this to work? The header file is present on Centos 7+.
If you show us the all the content of the mkmf.log
, we might see some hints.
Which ruby is used on the CentOS 6? The ruby built from the source or a RPM package? What mysql/mariadb library (devel) is used?
I have not checked the CentOS6 environment. I just show you the possible RPM packages you might need.
# yum install redhat-rpm-config gcc gcc-c++
# yum install mariadb-devel mariadb-server
# yum install ruby-devel
# yum install rh-ruby27-ruby-devel
This file is not present in gcc 4.4.7 which is the latest available. But the strange thing is that the gcc version does not change between the ruby versions.
What perplexes me here is the gcc 7.3.1, is that the version ruby was build with? That would explain the expected library that is there.
In your environment, both gcc 4.4.7 and gcc 7.3.1 are installed? How the gcc 7.3.1 is installed? I guess the gcc 4.4.7 is installed in /usr/bin/gcc
.
Maybe you need to show more command logs to show your environment such as gcc --version
, and the gcc related environment variables such as CFLAGS
, CC
.