You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mini_racer not starting: ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError) #295
Hi folks, I'm trying to use mini_racer in an environment in a Alpine LInux Docker container, with Ruby 2.7.2 and Rails 6.1.1. I understand this issue might be related to #63, but bear with me for a second.
The above messages led me to believe that there are in fact prebuilt libraries for this environment and everything would be okay, but when trying to start Rails afterwards... _ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError):
1: from /app/vendor/ruby/2.7.0/gems/mini_racer-0.6.4/lib/mini_racer.rb:14:in `<main>'
/app/vendor/ruby/2.7.0/gems/mini_racer-0.6.4/lib/mini_racer.rb:14:in `load': Error relocating /app/vendor/ruby/2.7.0/extensions/x86_64-linux-musl/2.7.0/mini_racer-0.6.4/mini_racer_extension.so: _ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError)
(I can provide the full stack trace if necessary).
Is this a case of mini_racer and/or libv8-node not working in Alpine, or should this setup be working and it's something else? Thanks.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux-musl]
/usr/gem/gems/mini_racer-0.8.0/lib/mini_racer.rb:14:in `load': Error relocating /usr/gem/extensions/x86_64-linux-musl/3.1.0/mini_racer-0.8.0/mini_racer_extension.so: _ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError)
from /usr/gem/gems/mini_racer-0.8.0/lib/mini_racer.rb:14:in `<top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `block in require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `each'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler.rb:186:in `require'
from /usr/gem/gems/jekyll-4.3.2/lib/jekyll/plugin_manager.rb:53:in `require_from_bundler'
from /usr/gem/gems/jekyll-4.3.2/exe/jekyll:11:in `<top (required)>'
from /usr/local/bundle/bin/jekyll:27:in `load'
from /usr/local/bundle/bin/jekyll:27:in `<main>'
I'm assuming you're using bundler? Providing Gemfile and Gemfile.lock might be helpful.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
indicates that you haven't set linux/arm64 as a platform in your Gemfile (I'm guessing that arm64 is your platform). Please take a look at Supported Ruby Versions & Troubleshooting in the README.
Are you sure you run docker with --platform linux/amd64 to get Rosetta translation? You're on arm64, but jekyll/jekyllonly provides linux/amd64 images.
Your example works on my M1 Pro (Sonoma 14.1) without any warning or errors.
Where do you get the Gemfile.lock from, @niko-zvt? Is that the lock file generated into the docker image?
When I use your Dockerfile 1:1 and diff it against the lockfile you've provided, I get the following diff. It is not surprising, as in the Dockerfile you added universal-darwin-8 as a platform. I build the image with: docker build --platform linux/amd64 ..
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
bundler: failed to load command: jekyll (/usr/gem/bin/jekyll)
/usr/gem/gems/mini_racer-0.8.0/lib/mini_racer.rb:14:in `load': Error relocating /usr/gem/extensions/x86_64-linux-musl/3.1.0/mini_racer-0.8.0/mini_racer_extension.so: _ZSt28__throw_bad_array_new_lengthv: symbol not found (LoadError)
from /usr/gem/gems/mini_racer-0.8.0/lib/mini_racer.rb:14:in `<top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `block in require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `each'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `require'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler.rb:186:in `require'
from /usr/gem/gems/jekyll-4.3.2/lib/jekyll/plugin_manager.rb:53:in `require_from_bundler'
from /usr/gem/gems/jekyll-4.3.2/exe/jekyll:11:in `<top (required)>'
from /usr/gem/bin/jekyll:25:in `load'
from /usr/gem/bin/jekyll:25:in `<top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:58:in `load'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:23:in `run'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/cli.rb:486:in `exec'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/cli.rb:31:in `dispatch'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/cli.rb:25:in `start'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/exe/bundle:48:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/exe/bundle:36:in `<top (required)>'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/exe/bundler:4:in `load'
from /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/exe/bundler:4:in `<top (required)>'
from /usr/local/bin/bundler:25:in `load'
from /usr/local/bin/bundler:25:in `<main>'
You also need to run the container with the correct platform docker run --platform linux/amd64 if you want to use Rosetta and x86 translation (I could have been more clear in #295 (comment)). This will remove the warning you're seeing.
But I'm getting the same error now, not sure why I missed that before, sorry.
It's not a general mini racer / alpine issue though. I used the following minimal example to check:
FROM ruby:3.2.2-alpine
RUN apk add musl-dev make g++
I can install and run mini_racer just fine with it (tested with a simple ruby -rmini_racer -e 'puts MiniRacer::Context.new.eval("41+1")'). bundle install from your Gemfile also works.
tl;dr
The jekyll image seems quite dated and is based on a 2 year old alpine 3.15. I'm not entirely sure what's going on, but since it's working with alpine 3.18 (what ruby:3.2.2-alpine is using), I suspect that this might be the cause.
Activity
tisba commentedon Oct 4, 2023
First, Ruby 2.7 is EOL and not (actively) supported by mini_racer, see https://github.com/rubyjs/mini_racer#supported-ruby-versions--troubleshooting.
mini_racer0.6.4 is also not the latest version. Can you try bump one or both?Also: Please make sure to run with the latest version of Rubygems (
gem update --system) and bundler.Alpine (musl libc) is unfortunately known for causing quite a few issues over the years 😞
niko-zvt commentedon Nov 2, 2023
See rubyjs/libv8#261
tisba commentedon Nov 2, 2023
Hey @niko-zvt 👋
I'm assuming you're using bundler? Providing
GemfileandGemfile.lockmight be helpful.indicates that you haven't set linux/arm64 as a platform in your Gemfile (I'm guessing that arm64 is your platform). Please take a look at Supported Ruby Versions & Troubleshooting in the README.
niko-zvt commentedon Nov 2, 2023
@tisba
Yes, I use M2 Pro (arm64). This happens after the docker image has been successfully built, but at the time the container is launched.
Dockerfile—> Base image ruby:3-alpine (linux/amd64).I tried both with and without the
--add-platform universal-darwin-8flag.See
GemfileGemfile.lock—> PLATFORMS: x86_64-linux-musltisba commentedon Nov 2, 2023
Are you sure you run docker with
--platform linux/amd64to get Rosetta translation? You're on arm64, butjekyll/jekyllonly provides linux/amd64 images.Your example works on my M1 Pro (Sonoma 14.1) without any warning or errors.
tisba commentedon Nov 3, 2023
Where do you get the Gemfile.lock from, @niko-zvt? Is that the lock file generated into the docker image?
When I use your Dockerfile 1:1 and diff it against the lockfile you've provided, I get the following diff. It is not surprising, as in the Dockerfile you added
universal-darwin-8as a platform. I build the image with:docker build --platform linux/amd64 ..niko-zvt commentedon Nov 5, 2023
@tisba, Hello! Yes, I generate Gemfile.lock inside docker container.
FROM --platform=linux/amd64 jekyll/jekyll--add-platform universal-darwin-8flag.--add-platform rubyflag.--add-platform x86_64-linuxflag.Input:
Output:
tisba commentedon Nov 5, 2023
You also need to run the container with the correct platform
docker run --platform linux/amd64if you want to use Rosetta and x86 translation (I could have been more clear in #295 (comment)). This will remove the warning you're seeing.But I'm getting the same error now, not sure why I missed that before, sorry.
It's not a general mini racer / alpine issue though. I used the following minimal example to check:
I can install and run mini_racer just fine with it (tested with a simple
ruby -rmini_racer -e 'puts MiniRacer::Context.new.eval("41+1")').bundle installfrom your Gemfile also works.tl;dr
The jekyll image seems quite dated and is based on a 2 year old alpine 3.15. I'm not entirely sure what's going on, but since it's working with alpine 3.18 (what
ruby:3.2.2-alpineis using), I suspect that this might be the cause.mathieujobin commentedon Nov 28, 2023
ARM proc are so much fun ...