Compiling native gem extensions is broken in v3.2.1
evanleck opened this issue · comments
Evan Lecklider commented
While attempting to upgrade to 3.2.1-jammy I ran into problems installing gems with native extensions like e.g. puma
. As a minimal example, this 3.2.0 Dockerfile works fine but the 3.2.1 version fails.
FROM rubylang/ruby:3.2.0-jammy
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential && \
rm -rf /var/lib/apt/lists/*
RUN gem install puma
CMD ["bash"]
This fails.
FROM rubylang/ruby:3.2.1-jammy
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential && \
rm -rf /var/lib/apt/lists/*
RUN gem install puma
CMD ["bash"]
The full error...
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/3.2.0/gems/nio4r-2.5.8/ext/nio4r
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.2.0 extconf.rb
checking for unistd.h... *** 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
--without-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=/usr/local/bin/$(RUBY_BASE_NAME)
--with-unistd-dir
--without-unistd-dir
--with-unistd-include
--without-unistd-include=${unistd-dir}/include
--with-unistd-lib
--without-unistd-lib=${unistd-dir}/lib
/usr/local/lib/ruby/3.2.0/mkmf.rb:490:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/3.2.0/mkmf.rb:616:in `block in try_compile'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:565:in `with_werror'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:616:in `try_compile'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:1157:in `block in have_header'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:989:in `block in checking_for'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:354:in `block (2 levels) in postpone'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:324:in `open'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:354:in `block in postpone'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:324:in `open'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:350:in `postpone'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:988:in `checking_for'
from /usr/local/lib/ruby/3.2.0/mkmf.rb:1156:in `have_header'
from extconf.rb:15:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/nio4r-2.5.8/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/3.2.0/gems/nio4r-2.5.8 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/nio4r-2.5.8/gem_make.out
Error: building at STEP "RUN gem install puma": while running runtime: exit status 1
The `mkmf.log` file...
LD_LIBRARY_PATH=.:/usr/local/lib "gcc -o conftest -I/usr/local/include/ruby-3.2.0/x86_64-linux -I/usr/local/include/ruby-3.2.0/ruby/backward -I/usr/local/include/ruby-3.2.0 -I. -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef -fPIC conftest.c -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby -lm -lpthread -lc"
/usr/bin/ld: cannot find -lruby: No such file or directory
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
Hiroshi SHIBATA commented
https://github.com/ruby/ruby-docker-images/blob/master/Dockerfile#L152
It may mistake to use RUBY_VERSION_MM
instead of RUBY_SO_SUFFIX_MM
.
Kenta Murata commented
Evan Lecklider commented
No worries @mrkn thanks for merging and kicking off the build!