ruby-on-railsexecjs

How to replace therubyracer javascript runtime


How do I replace the therubyracer gem? I'm really stuck.

We have been using the therubyracer gem for our Rails asset pipeline. However, it is using dependencies which are past their end of life and have security vulnerabilities. The latest version 0.12.3 is from January 05, 2017.

I have looked at the mini_racer gem, but we deploy to FreeBSD and the latest version supported on FreeBSD is 0.1.14 from August 24, 2017. We develop on macOS and my compile of this version of mini_racer gets errors, one of which because CreateDefaultPlatform has been removed from V8.

The list of runtimes supported by execjs, at https://github.com/rails/execjs lists Node.js and Google V8 but the links go to pages which don't look like gems I can replace in my Gemfile, neither do those pages have documentation on how to use their runtime for execjs. I honestly am stuck with no idea how to use a newer runtime in my Rails pipeline.


Solution

  • Using therubyracer has generally been superseded by using a NodeJS installation that is on the machine itself, meaning it wouldn't be installed as a gem. Gem installations that require a JS runtime to build should be smart enough to find your locally installed NodeJS.

    So locally, you should just be able to remove therubyracer from your Gemfile, assuming you don't have other gems that depend on it. If you do, those are probably outdated or abandoned. Your build pipeline will need to be modified to install NodeJS before the bundle install.