[Java] [Error Resolving] Resolving method when the error Could not find a JavaScript runtime. appears after upgrading Catalina!

less than 1 minute read

error contents

After upgrading from macOS Catalina 10.15.3 to 10.15.6, the following error occurred when $bin/rspec was used.

terminal


$bin/rspec
/.../.../.../vendor/bundle/ruby/2.5.0/gems/execjs2.7.0/lib/execjs/runtimes.rb:58:in `autodetect':
Could not find a JavaScript runtime.
See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

I am getting an error that the JavaScript runtime cannot be found.

Environment

  • macOS Catalina 10.15.6 (after version upgrade)
  • ruby ‘2.5.7’
  • rails ‘5.2.3’
  • rspec-rails ‘4.0.0.beta2’

Solution

Conclusion: Add "gem'mini_racer', platforms: :ruby" to Gemfile

If you look at the error log, you can see the Github link, so check the link destination. After checking, it seems good to add a gem called mini_racer to the Gemfile.

Gemfile


(abridgement)
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem'mini_racer', platforms: :ruby
(abridgement)

Uncomment this part of the Gemfile. After that, do $bundle install, When I tried $bin/rspec again, the test ran normally.