Ruby-on-rails 运行 rails 应用程序时出错 - ExecJS::RuntimeError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8362458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error when running rails app - ExecJS::RuntimeError
提问by JoeMoe1984
I tried googling this and I haven't found an answer yet to my problem.
我试着用谷歌搜索这个,但我还没有找到我的问题的答案。
I am trying to run a simple controller script through rails and it is giving me this error when I reach the page.
我试图通过 rails 运行一个简单的控制器脚本,当我到达页面时它给了我这个错误。
ExecJS::RuntimeError in Say#hello
Obviously Say is the controller and hello is the method. Further down the page I get more info about the error.
显然 Say 是控制器, hello 是方法。在页面下方,我获得了有关错误的更多信息。
dyld: unknown required load command 0x80000022
(in /Users/JoeMoe/Sites/demoRails/app/assets/javascripts/say.js.coffee)
I have checked this file and there is nothing in it besides the commented code. Is there supposed to be something in here?
我检查了这个文件,除了注释的代码外,没有任何内容。这里面应该有什么吧?
Here is whats in the say.js.coffee file
这是 say.js.coffee 文件中的内容
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
Down the page some more I see I can do an Application Trace which shows me.
在页面下方,我看到我可以做一个显示我的应用程序跟踪。
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__169683399_21885150'
I can also do the framework trace as well. This is going to be a long list by the way.
我也可以进行框架跟踪。顺便说一下,这将是一个很长的清单。
execjs (1.2.9) lib/execjs/external_runtime.rb:129:in `exec_runtime'
execjs (1.2.9) lib/execjs/external_runtime.rb:27:in `block in exec'
execjs (1.2.9) lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
execjs (1.2.9) lib/execjs/external_runtime.rb:26:in `exec'
execjs (1.2.9) lib/execjs/external_runtime.rb:18:in `eval'
execjs (1.2.9) lib/execjs/external_runtime.rb:32:in `call'
coffee-script (2.2.0) lib/coffee_script.rb:57:in `compile'
tilt (1.3.3) lib/tilt/coffee.rb:46:in `evaluate'
tilt (1.3.3) lib/tilt/template.rb:76:in `render'
sprockets (2.0.3) lib/sprockets/context.rb:175:in `block in evaluate'
sprockets (2.0.3) lib/sprockets/context.rb:172:in `each'
sprockets (2.0.3) lib/sprockets/context.rb:172:in `evaluate'
sprockets (2.0.3) lib/sprockets/bundled_asset.rb:171:in`build_dependency_context_and_body'
sprockets (2.0.3) lib/sprockets/bundled_asset.rb:135:in `dependency_context'
....
There is more but its a pretty long list and I don't want to bore you. Let me know if you need the full list and I will paste it in.
还有更多,但它是一个很长的清单,我不想让你感到厌烦。如果您需要完整列表,请告诉我,我会将其粘贴进去。
I am running Mac OS X with the following - Ruby 1.9.2 - Rails 3.1.0 - Gem 1.8.10 - sqlite3 3.7.9
我正在使用以下命令运行 Mac OS X - Ruby 1.9.2 - Rails 3.1.0 - Gem 1.8.10 - sqlite3 3.7.9
回答by RailsZilla
you have to install an additional gem for javascript. edit gemfile and add gem 'therubyracer'. You can then run bundle to install the new gem.
你必须为 javascript 安装一个额外的 gem。编辑 gemfile 并添加 gem 'therubyracer'。然后你可以运行 bundle 来安装新的 gem。
here is your solution in detail: http://www.railszilla.com/2011/12/rails-3-coffescript-execjs/
这是您的详细解决方案:http: //www.railszilla.com/2011/12/rails-3-coffescript-execjs/
回答by Martin
It happened to me too! You need to install "nodejs". As I work with Ubuntu Linux I did:
它也发生在我身上!您需要安装“ nodejs”。当我使用 Ubuntu Linux 时,我做了:
apt-get install nodejs
Source: http://forums.pragprog.com/forums/148/topics/9665#posts-26576(Sam Ruby's post)
来源:http: //forums.pragprog.com/forums/148/topics/9665#posts-26576(Sam Ruby 的帖子)
回答by Aleem
If you are having this problem in production server this might be due to memory usage. while doing assets precompilation server use lot of memory.
如果您在生产服务器中遇到此问题,这可能是由于内存使用造成的。在做资产预编译服务器时使用大量内存。
consider restarting your production server.
回答by ajinkya Jahagirdar
None of the above worked for me . . .
I installed gem 'coffee-script-source', '1.8.0'.
以上都不适合我。. . 我安装了gem 'coffee-script-source', '1.8.0'.
Then application started running without any problem.
然后应用程序开始运行,没有任何问题。
回答by Ali Hassan Mirza
Seems like javascript runner is missing you just need to do
似乎缺少 javascript runner 你只需要做
gem 'therubyracer'
then
然后
bundle install
then restart the server if you are using the production server then consider restart the production server.
如果您使用的是生产服务器,则重新启动服务器,然后考虑重新启动生产服务器。
It will definitely solve your problem,
绝对能解决你的问题
cheers
干杯
回答by PanXo
It looks like you might be missing a few gems.
看起来您可能缺少一些宝石。
Add to your Gemfile:
添加到您的 Gemfile:
gem 'therubyracer'
gem 'execjs'
And then run $ bundle installto install them.
然后运行$ bundle install安装它们。

