Question

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.

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

Was it helpful?

Solution 2

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.

OTHER TIPS

By the looks of it one of the javascript files is not valid in some way.

I am presuming that everything runs correctly in development mode, that is everything functions correctly in the browser?

If this is so, the code runs correctly in development because all the files are served in debug mode - they are not concatenated or compressed. When compiled they are first concatenated and then compressed.

The problem will likely be a syntax error in one of the included files in the form of a missing semicolon. Javascript compressors need these to determine where one block of code ends and another begins. The first place to check is the end of plugin definitions. Assuming the problem is in one file only you could remove just one file at time, compile it until it runs, and you have your culprit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top