Rails rake db: migrate javascript runtime required?

In my first rails project (using mysql), I tried to run the rake db:create command, but I got the following error:

Could not find JavaScript executable. See https://github.com/sstephenson/execjs for a list of available battery life.

So, I included the gem 'therubyracer', require: "v8" in my Gemfile and executed a bundle install . The problem is resolved, but it left some doubts.

Can someone give me an explanation why javascript runtime is required to complete this task? I am new to Ruby and RoR, so it seems rather strange to me, why does RoR use javascript to create a database?

+4
source share
2 answers

You need javascript runtime because Rails now uses the resource pipeline . Rails does not need it to run your migrations, but when you run rake db:migrate , the rake task loads your rails application, which requires javascript to run to run. There is virtually no connection between migrations and javascript runtime, but your application will not load without it.

+8
source

This is for server-processed javascript. It is used by NodeJS, Coffeescript and some more javascript stones. If you are not using any of them, you can simply remove them from your gemfile and no runtime is required.

+2
source

Source: https://habr.com/ru/post/1384121/


All Articles