mini_racer: v0.4.0 fails to build on ruby:3.0-alpine
With https://github.com/rubyjs/mini_racer/pull/186 being included in v0.4.0 I was hopeful that mini_racer would be installable in alpine containers. Unfortunately, it isn’t quite working for me. Here’s a minimal Dockerfile to demonstrate the issue that I hit:
FROM ruby:3.0.1-alpine
RUN apk update && apk upgrade && \
apk add --no-cache build-base && \
gem update --system && gem install bundler
RUN gem install mini_racer -v 0.4.0
Here’s the error:
> [3/3] RUN gem install mini_racer -v 0.4.0:
#6 2.994 Successfully installed libv8-node-15.14.0.1-x86_64-linux-musl
#6 2.994 Building native extensions. This could take a while...
#6 4.642 ERROR: Error installing mini_racer:
#6 4.642 ERROR: Failed to build gem native extension.
#6 4.642
#6 4.642 current directory: /usr/local/bundle/gems/mini_racer-0.4.0/ext/mini_racer_extension
#6 4.642 /usr/local/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.0.0 -r ./siteconf20210506-1-u8eo5j.rb extconf.rb
#6 4.642 checking for -lpthread... yes
#6 4.642 creating Makefile
#6 4.642
#6 4.642 current directory: /usr/local/bundle/gems/mini_racer-0.4.0/ext/mini_racer_extension
#6 4.642 make DESTDIR\= clean
#6 4.642
#6 4.642 current directory: /usr/local/bundle/gems/mini_racer-0.4.0/ext/mini_racer_extension
#6 4.642 make DESTDIR\=
#6 4.642 compiling mini_racer_extension.cc
#6 4.642 In file included from /usr/local/include/ruby-3.0.0/ruby/ruby.h:39,
#6 4.642 from /usr/local/include/ruby-3.0.0/ruby.h:38,
#6 4.642 from mini_racer_extension.cc:2:
#6 4.642 /usr/local/include/ruby-3.0.0/ruby/internal/memory.h:276:16: error: conflicting declaration of 'void* ruby_nonempty_memcpy(void*, const void*, size_t)' with 'C' linkage
#6 4.642 276 | #define memcpy ruby_nonempty_memcpy
#6 4.642 | ^~~~~~~~~~~~~~~~~~~~
#6 4.642 /usr/local/include/ruby-3.0.0/ruby/internal/memory.h:266:1: note: previous declaration with 'C++' linkage
#6 4.642 266 | ruby_nonempty_memcpy(void *dest, const void *src, size_t n)
#6 4.642 | ^~~~~~~~~~~~~~~~~~~~
#6 4.642 mini_racer_extension.cc: In function 'v8::Local<v8::Value> convert_ruby_to_v8(v8::Isolate*, v8::Local<v8::Context>, VALUE)':
#6 4.642 mini_racer_extension.cc:546:96: warning: ignoring return value of 'v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)', declared with attribute 'warn_unused_result' [-Wunused-result]
#6 4.642 546 | array->Set(context, i, convert_ruby_to_v8(isolate, context, rb_ary_entry(value, i)));
#6 4.642 | ^
#6 4.642 In file included from mini_racer_extension.cc:5:
#6 4.642 /usr/local/bundle/gems/libv8-node-15.14.0.1-x86_64-linux-musl/vendor/v8/include/v8.h:3719:37: note: declared here
#6 4.642 3719 | V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
#6 4.642 | ^~~
#6 4.642 mini_racer_extension.cc:556:78: warning: ignoring return value of 'v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)', declared with attribute 'warn_unused_result' [-Wunused-result]
#6 4.642 556 | convert_ruby_to_v8(isolate, context, rb_ary_entry(pair, 1)));
#6 4.642 | ^
#6 4.642 In file included from mini_racer_extension.cc:5:
#6 4.642 /usr/local/bundle/gems/libv8-node-15.14.0.1-x86_64-linux-musl/vendor/v8/include/v8.h:3716:37: note: declared here
#6 4.642 3716 | V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
#6 4.642 | ^~~
#6 4.642 mini_racer_extension.cc: In function 'VALUE rb_external_function_notify_v8(VALUE)':
#6 4.642 mini_racer_extension.cc:1165:46: warning: ignoring return value of 'v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)', declared with attribute 'warn_unused_result' [-Wunused-result]
#6 4.642 1165 | .ToLocalChecked());
#6 4.642 | ^
#6 4.642 In file included from mini_racer_extension.cc:5:
#6 4.642 /usr/local/bundle/gems/libv8-node-15.14.0.1-x86_64-linux-musl/vendor/v8/include/v8.h:3716:37: note: declared here
#6 4.642 3716 | V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
#6 4.642 | ^~~
#6 4.642 mini_racer_extension.cc:1190:58: warning: ignoring return value of 'v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)', declared with attribute 'warn_unused_result' [-Wunused-result]
#6 4.642 1190 | .ToLocalChecked());
#6 4.642 | ^
#6 4.642 In file included from mini_racer_extension.cc:5:
#6 4.642 /usr/local/bundle/gems/libv8-node-15.14.0.1-x86_64-linux-musl/vendor/v8/include/v8.h:3716:37: note: declared here
#6 4.642 3716 | V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
#6 4.642 | ^~~
#6 4.642 make: *** [Makefile:213: mini_racer_extension.o] Error 1
#6 4.642
#6 4.642 make failed, exit code 2
#6 4.642
#6 4.642 Gem files will remain installed in /usr/local/bundle/gems/mini_racer-0.4.0 for inspection.
#6 4.642 Results logged to /usr/local/bundle/extensions/x86_64-linux-musl/3.0.0/mini_racer-0.4.0/gem_make.out
------
executor failed running [/bin/sh -c gem install mini_racer -v 0.4.0]: exit code: 1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 31 (8 by maintainers)
Commits related to this issue
- Update extconf.rb Because of https://github.com/rubyjs/mini_racer/issues/199 — committed to sagarjauhari/mini_racer by sagarjauhari 3 years ago
I used the suggestions here and was able to get it working with a patch. My Dockerfile:
So confirming that the suggestions are working.
Since https://bugs.ruby-lang.org/issues/17788 fixes the issue on Ruby 3.1 I created a backport request for Ruby 3.0 in https://bugs.ruby-lang.org/issues/18574
This appears to be working now @bryanp , just tried your dockerfile and it is passing.
So, I looked into an implementation, and to have the widest support possible and good feedback for the user I’m going to introduce a bit of compiler, feature, and version checking (that CXX11_TEST is a bit outdated and limited in scope). I think the README is due for some informative updates as well.
Might take a bit of time to get this right, but everyone will end up happier.
It would be better to make changes so that it works out of the box. I’ll see to it.
OK, so a workaround would be to install and use clang:
… if it were not for the required
-fdeclspecor-fms-extensionsflags which need some patching ofextconf.rb: