Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Rails rake db:migrate needs a javascript runtime?

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

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

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

Could somebody give me an explanation about why a javascript runtime is needed for this kind of task? I'm new to Ruby and RoR so this seems quite strange to me, why do RoR use javascript for creating a database?

like image 451
marcio Avatar asked Dec 28 '22 10:12

marcio


1 Answers

You need a javascript runtime because now Rails uses an asset pipeline. Rails doesn't need it to run your migrations but when you run rake db:migrate, the rake task loads your rails application that needs a javascript runtime to start. Practically, there is no relation between the migrations and the javascript runtime but your app won't load without it.

like image 119
lucapette Avatar answered Jan 13 '23 12:01

lucapette