升级Rails至3.2.11时出现问题:在Static_pages#home中出现ExecJS::RuntimeError错误

4

我刚刚将Rails从3.2.10升级到3.2.11,并没有对我的应用程序进行其他更改。

突然间,我的网站无法加载,并显示以下错误信息:

ExecJS::RuntimeError in Static_pages#home

有人知道为什么Rails 3.2.11的更改会导致这个问题吗?

ExecJS::RuntimeError in Static_pages#home

Showing C:/Sites/av_reports/app/views/layouts/application.html.erb where line #11 raised:


  (in C:/Sites/av_reports/app/assets/javascripts/password_resets.js.coffee)
Extracted source (around line #11):

8:  <meta name="author" content="">
9:  
10:     <%= stylesheet_link_tag    "application", :media => "all" %>
11:     <%= javascript_include_tag "application" %>
12:     <%= csrf_meta_tags %>
13:     <%= render 'layouts/shim' %>
14:   </head>

我的 /app/assets/javascripts/password_resets.js.coffee 文件包含三行已注释的文本,因此我猜想那不是问题所在。

是否有 gem 依赖关系的更改或其他可能导致问题的原因?

编辑

我的 application.js 文件如下:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
2个回答

4
所以…显然这不是Rails 3.2.11升级问题。潜在的问题是ExecJS在Windows中的工作方式。我目前在Windows 8上运行我的开发环境。
在升级到Rails 3.2.11之前,以上错误消息会出现在服务器日志中,但它不会停止服务器。在Rails 3.2.11中,页面将无法加载。
解决方案是编辑Ruby1.9.3\lib\ruby\gems\1.9.1\gems\execjs-1.4.0\lib\execjs\runtimes.rb文件:
(原始的不起作用的代码):
JScript = ExternalRuntime.new(
    :name        => "JScript",
    :command     => "cscript //E:jscript //Nologo //U",
    :runner_path => ExecJS.root + "/support/jscript_runner.js",
    :encoding    => 'UTF-16LE' # CScript with //U returns UTF-16LE
)

(更新的工作代码):
JScript = ExternalRuntime.new(
    :name        => "JScript",
    :command     => "cscript //E:jscript //Nologo",
    :runner_path => ExecJS.root + "/support/jscript_runner.js",
    :encoding    => 'UTF-8' # CScript with //U returns UTF-16LE
)

感谢这篇评论:https://github.com/sstephenson/execjs/issues/81#issuecomment-9892952和这个讨论:https://dev59.com/zWYr5IYBdhLWcg3wn7cc#14119187,对解决这个问题非常有帮助。

0

我遇到了一些问题,但我使用的是Ruby2.0.0

解决方法是编辑Ruby2.0.0\lib\ruby\gems\2.0.0\gems\execjs-2.2.1\lib\execjs\runtimes.rb文件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接