最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Does Rails rake db:migrate needs a javascript runtime? - Stack Overflow

programmeradmin2浏览0评论

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

Could not find a JavaScript runtime. See 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?

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

Could not find a JavaScript runtime. See https://github./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?

Share Improve this question edited Dec 1, 2011 at 14:36 marcio asked Dec 1, 2011 at 14:20 marciomarcio 10.5k13 gold badges57 silver badges86 bronze badges 5
  • 1 What library did raise that error? Try again without the rubyracer and with rake db:create --trace – Reactormonk Commented Dec 1, 2011 at 14:23
  • 1 probably coffee-rails and uglifier – Ben Commented Dec 1, 2011 at 14:24
  • That's it @Ben, coffee-rails was causing the dependency! – marcio Commented Dec 1, 2011 at 15:07
  • Thanks @tass, didn't know about the --trace parameter – marcio Commented Dec 1, 2011 at 15:07
  • +1 for asking this question as i faced same problem. – Neeraj Commented Jan 28, 2013 at 8:12
Add a ment  | 

2 Answers 2

Reset to default 8

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.

This is for serverside executed javascript. It is used by NodeJS, Coffeescript and quite a few more javascript gems. If you dont use any of those, you can just remove them from your gemfile and no runtime will be required.

发布评论

评论列表(0)

  1. 暂无评论