Rails资产预编译神秘错误

Rails资产预编译神秘错误

本文介绍了Rails资产预编译神秘错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在资产预编译中确实遇到了一个令人讨厌且持续存在的问题,我似乎无法自己解决.编译总是会在没有错误的某些文件中失败.例如,下面的错误是在仅带有注释的文件copies.js.coffee中.如果删除该文件,则另一个文件将出现错误.我所有资产文件的类型都是us-ascii-任何文件中都没有奇怪的字符.我正在使用Rails 3.1.3.我已经使用Ruby 1.9.2和1.9.3进行了尝试-没什么区别.

I have a really nasty and persistent problem in assets precompile which I seem not to be able to solve by myself. The compilation always fails in some file that does not have an error. For example the error below is in the file copies.js.coffee that has only a comment. If I delete that file, another file will have the error. The type of all my asset files is us-ascii - no strange characters in any file. I am using Rails 3.1.3. I have tried both with Ruby 1.9.2 and 1.9.3 - no difference.

$ rake assets:precompile --trace
(in /cygdrive/c/Development/artwork2)
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/kari/.rvm/rubies/ruby-1.9.3-p0/bin/ruby.exe /home/kari/.rvm/gems/ruby-1.9.3-p0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
湉異⁴牅潲㩲唠歮潮湷漠瑰潩⼢祣摧楲敶振唯敳獲欯牡⽩灁䑰瑡⽡潌慣⽬敔灭支數橣㉳㄰〲ㄱⴲ㔵〲㐭瀶湸⸱獪•灳捥晩敩⹤਍
  (in /cygdrive/c/Development/artwork2/app/assets/javascripts/copies.js.coffee)
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:150:in `exec_runtime'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:27:in `block in exec'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:26:in `exec'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:18:in `eval'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:32:in `call'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/coffee-script-2.2.0/lib/coffee_script.rb:57:in `compile'
/home/kari/.rvm/gems/ruby-1.9.3-p0/gems/tilt-1.3.3/lib/tilt/coffee.rb:46:in `evaluate'

这真的很烦人,我无法前进.我已经尝试了从这里和其他地方发现的几乎所有东西.

This is really annoying and I am not able to get forward. I have tried almost everything I have found from here and from elsewhere.

另外:我在cygwin和Ubuntu中都在rvm下都尝试过.

An addition: I have tried this both in cygwin and in Ubuntu under rvm in both.

推荐答案

问题出在咖啡架上.我从资产中删除了所有生成的咖啡文件.它们仅包含生成的评论,没有其他内容.之后,资产应该按原样进行编译.某个地方一定有一个错误的错误.花了几个小时.感谢Richard提出的方法.

The problem was in coffee-rails. I removed all generated coffee files from assets. They contained only generated comments, nothing else. After that the assets compiled as they should have been. There must be a bad bug somewhere. It took couple of hours. Thank you Richard for suggesting the method.

这篇关于Rails资产预编译神秘错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 17:47