use*_*078 101 javascript ruby windows ruby-on-rails asset-pipeline
更新: 科林建议删除行// = require_tree.已经解决了这个问题.
我已经浪费了2天时间试图跟踪每个建议并解决我的问题.我试图按照Windows机器上的http://ruby.railstutorial.org书籍,并且不能为我的生活经历以下讨厌的错误.
ExecJS::RuntimeError in Static_pages#home
Showing C:/Users/.../bootcamp-sample-app/app/views/layouts/application.html.erb where line #6 raised:
["ok","(function() {\n\n\n\n}).call(this);\n"]
(in C:/Users/.../bootcamp-sample-app/app/assets/javascripts/sessions.js.coffee)
Extracted source (around line #6):
3: <head>
4: <title><%= full_title(yield(:title)) %></title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: <%= render 'layouts/shim' %>
9: </head>
Rails.root: C:/Users/.../bootcamp-sample-app
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___487732698_30422172'
Request
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有的建议,包括用msi安装nodejs,使用execjs 1.3.0和其他我甚至不记得的东西.这是gem文件
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
gem 'guard-rspec', '0.5.5'
gem 'guard-cucumber'
end
group :development do
gem 'annotate', '2.5.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'coffee-script'
gem 'uglifier'
end
gem 'jquery-rails', '2.0.2'
gem 'execjs'
# Gems on Linus/Mac
#gem 'therubyracer'
group :test do
gem 'capybara', '1.1.2'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
gem 'factory_girl_rails', '1.4.0'
gem 'cucumber-rails', '1.2.1', require: false
gem 'database_cleaner', '0.7.0'
# Test gems on Linux
# gem 'rb-inotify', '0.8.8'
# gem 'libnotify', '0.5.9'
# Test gems on Macintosh OS X
# gem 'selenium-webdriver', '~> 2.22.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
# Test gems on Windows
# gem 'rb-fchange', '0.0.5'
# gem 'rb-notifu', '0.0.4'
# gem 'win32console', '1.3.0'
end
group :production do
# gem 'therubyracer'
gem 'pg', '0.12.2'
end
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
#gem 'debugger''
Run Code Online (Sandbox Code Playgroud)
这是sessions.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/
Run Code Online (Sandbox Code Playgroud)
的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_tree .
//= require bootstrap
Run Code Online (Sandbox Code Playgroud)
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是控制台内容
Processing by StaticPagesController#home as HTML
Rendered static_pages/home.html.erb within layouts/application (45.0ms)
Completed 500 Internal Server Error in 1136ms
ActionView::Template::Error (["ok","(function() {\n\n\n\n}).call(this);\n"]
(in C:/Users/.../bootcamp-sample-app/app/assets/javascripts/sessions.js.coffee)):
3: <head>
4: <title><%= full_title(yield(:title)) %></title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: <%= render 'layouts/shim' %>
9: </head>
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___487732698_30422172'
Rendered C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
Rendered C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (34.0ms)
Run Code Online (Sandbox Code Playgroud)
我已经安装了Devkit并尝试了各种宝石,但请建议可以帮助我在Windows上开发的更改.我用rubyinstaller做了一切.
我错过了什么?
Kev*_*n P 240
我的朋友几个月前在Win 8 RTM上尝试了一个Rails教程并遇到了这个错误.不确定Windows 7中是否存在此问题,但这可能会有所帮助.
选项:
1)删除 //= require_tree ./忽略问题 -正如ColinR所述,此行不应该首先引起问题.ExecJS与系统上的JavaScript运行时正常工作存在实际问题,删除此行只是忽略了这一事实.
2)安装Node.js /跑掉 - 许多人似乎最终安装了Node.js并使用它而不是已经在他们的系统上运行的JavaScript运行时.虽然这是一个有效的选项,但它还需要额外的软件,并且只能避免原始问题,即ExecJS无法正常使用系统上的JavaScript运行时.如果您的系统上现有的JavaScript运行时应该可以工作,为什么不让它工作而不是安装更多软件?根据ExecJS创建者的说法,Windows内置的运行时实际上是受支持的......
ExecJS允许您从Ruby运行JavaScript代码.它会自动选择可用于评估JavaScript程序的最佳运行时,然后将结果作为Ruby对象返回给您.
ExecJS支持这些运行时:
- therubyracer - 嵌入在Ruby中的Google V8
- therubyrhino - Mozilla Rhino嵌入在JRuby中
- Node.js的
- Apple JavaScriptCore - 包含在Mac OS X中
- Microsoft Windows脚本宿主(JScript)
(来自github.com/sstephenson/execjs#execjs)
3)实际修复问题/学习 -使用选项1和2的知识来搜索其他解决方案.在实际查找有关我们遇到的根本问题的信息之前,我无法告诉您在看到选项1或2是已接受的解决方案时关闭了多少个网页.我们一直关注的唯一原因是我们无法相信Rails团队会(1)在导致问题的每个脚手架生成的项目中插入一行代码,或者(2)要求我们安装其他软件以运行该默认值代码行.所以我们最终得到了根本问题的解决办法(你的里程可能会有所不同).
适用于我们的修复:
在有问题的系统上,找到ExecJS的runtimes.rb文件.看起来像这样.制作找到的备份文件的副本.打开原始runtimes.rb进行编辑.找到以该行开头的部分JScript = ExternalRuntime.new(.在该部分中,在包含的行上:command => "cscript //E:jscript //Nologo //U",- 删除//U唯一的.然后在包含的行:encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE- 将UTF-16LE更改为UTF-8.将更改保存到文件.现在应该读取该文件的这一部分:
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
)
Run Code Online (Sandbox Code Playgroud)
接下来,停止然后重新启动Rails服务器并在浏览器中刷新产生原始错误的页面.希望页面现在加载没有错误.这是我们最初发布结果的ExecJS问题主题:https://github.com/sstephenson/execjs/issues/81#issuecomment-9892952
如果这不能解决问题,您可以随时使用您希望制作的备份副本覆盖已修改的runtimes.rb,并且所有内容都将回到原点.在这种情况下,请考虑选项3并继续搜索.让我们知道什么最终对你有用..除非它删除require_tree或安装node.js,已经有很多东西可以解决.:)
sna*_*ssr 14
有相同的问题OS-Windows 8 Error-'ExecJS :: RuntimeError ...'解决方案 - 缺少Node.js
gus*_*ics 12
我遇到了这个问题,并且正在使用这个rails gem文件来运行Windows 8
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required # in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :production do
gem 'pg', '0.12.2'
end
Run Code Online (Sandbox Code Playgroud)
去http://nodejs.org/download/ 安装 - 重新启动机器,一切正常.
我赞成学习路线.似乎问题源于此
IO.popen(command, options) { |f| output = f.read }
Run Code Online (Sandbox Code Playgroud)
返回一个空字符串execjs\external_runtine.rb(版本1.4.0中的第173行).这就是错误消息不包含文本的原因.建议的更改对我不起作用.我换UTF-16LE到UTF-8,但它仍然返回一个空字符串.我删除\\U了command- 这至少返回了文本,但它的编码错误 - 在浏览器中显示为中文字符.
根据这篇MSDN博客文章,使用//U标志并重定向到文件会cscript导致使用返回结果UTF-16.
然后,奇迹般地,它使用as 和as (@#%$&^ @ $%!!!?!?!).那好吧.command"cscript //E:jscript //Nologo"encoding"UTF-8"
| 归档时间: |
|
| 查看次数: |
73418 次 |
| 最近记录: |