gpt4 book ai didi

ruby-on-rails - 升级到 Rails 3.2.11 时出现问题:Static_pages#home 中的 ExecJS::RuntimeError

转载 作者:行者123 更新时间:2023-12-03 00:20:12 27 4
gpt4 key购买 nike

我刚刚从 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 文件包含 3 行注释掉的文本,所以我猜这不是问题。

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 .

最佳答案

所以...显然这根本不是 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://stackoverflow.com/a/14119187/1757424寻求有关此问题的帮助。

关于ruby-on-rails - 升级到 Rails 3.2.11 时出现问题:Static_pages#home 中的 ExecJS::RuntimeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14283465/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com