admin管理员组文章数量:1390547
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
2 Answers
Reset to default 8You 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.
本文标签: Does Rails rake dbmigrate needs a javascript runtimeStack Overflow
版权声明:本文标题:Does Rails rake db:migrate needs a javascript runtime? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744729226a2621944.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论