ExecJS:RuntimeUnavailable: Could not find a Javascript runtime Docker app

Viewed 3645

I am trying to build a container rails app using Docker. In my Gemfile, execjs gem is already present. However, on running the server i get the below error

ExecJS:RuntimeUnavailable: Could not find a javascript runtime

Upon digging further, I found out adding gem therubyracer or mini_racer solves the issue. however, with that addition I get the below error.

Unable to load application: LoadError: Error relocating /usr/local/bundle/gems/therubyracer-0.12.3/lib/v8/init.so: __vfprintf_chk: symbol not found - /usr/local/bundle/gems/therubyracer-0.12.3/lib/v8/init.so

Please help

2 Answers

This issue is raise because of therubyracer gem is not actively maintain by owner.

I also faced same issue when move to ruby:2.6.5-slim to ruby:2.6.5-alpine docker image. After few hours googling I found the solution to solve it.

install nodejs and python v2.7 package and add gem in your Gemfile
gem 'libv8-alpine', '~> 6.7', '>= 6.7.288.46.1'
and remove gem 'therubyracer' from Gemfile.

Refefences:
libv8-alpine
enter link description here

Upgrade execjs gem.

On modern Macs, the JSC lives in a different place. I was getting this error message when setting up our Rails app on a new M1 Mac mini running Big Sur.

Upgrading to execjs 2.8.0+ fixed the issue for me:

Gemfile

gem "execjs", "2.8.1"

You can see the merge commit here:

https://github.com/rails/execjs/pull/98

Related