我试着用谷歌搜索这个,但我还没有找到我的问题的答案。
我正在尝试通过 Rails 运行一个简单的 Controller 脚本,但当我到达页面时出现此错误。
ExecJS::RuntimeError in Say#hello
显然 Say 是 Controller ,hello 是方法。在页面的下方,我获得了有关该错误的更多信息。
dyld: unknown required load command 0x80000022
(in /Users/JoeMoe/Sites/demoRails/app/assets/javascripts/say.js.coffee)
我检查了这个文件,里面除了注释代码外什么都没有。这里应该有东西吗?
这是 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/
在页面下方,我看到我可以做一个应用程序跟踪,它会显示给我。
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__169683399_21885150'
我也可以进行框架跟踪。顺便说一下,这将是一个很长的列表。
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'
....
还有更多,但列表很长,我不想让您感到厌烦。如果您需要完整列表,请告诉我,我会将其粘贴进去。
我在 Mac OS X 上运行以下命令 - ruby 1.9.2 - rails 3.1.0 - gem 1.8.10 -sqlite3 3.7.9
最佳答案
您必须为 javascript 安装一个额外的 gem。 编辑 gemfile 并添加 gem 'therubyracer'。然后您可以运行 bundle 来安装新的 gem。
这是您的详细解决方案: http://www.railszilla.com/2011/12/rails-3-coffescript-execjs/
关于ruby-on-rails - 运行 Rails 应用程序时出错 - ExecJS::RuntimeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8362458/