Rails debug assets: precompile: how to identify files (s)?

I am a little desperate; tried to debug this problem for several days. Does anyone know how to troubleshoot? Perhaps identify the file (s) that cause the encoding problem?

FWIW: This works in a dev environment: RAILS_ENV=production bundle exec rake assets:precompile --trace

But this does not work on the "production" server ... I donโ€™t know how to start troubleshooting:

 $ RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile --trace ** Invoke assets:precompile (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment ** Invoke environment (first_time) ** Execute environment ** Execute assets:precompile I, [2013-09-26T10:54:13.904512 #8431] INFO -- : Writing /rails/myapp/releases/20130926175008/public/assets/sort_asc-9348a2efdfbcfa28135e10d4f7b42d0d.png I, [2013-09-26T10:54:13.945109 #8431] INFO -- : Writing /rails/myapp/releases/20130926175008/public/assets/sort_asc_disabled-30ae6b96c67982047ca4cfa0b8ce81b2.png I, [2013-09-26T10:54:14.007435 #8431] INFO -- : Writing /rails/myapp/releases/20130926175008/public/assets/sort_both-8018c940cc83bb4cf2bf0e68e41fdcc0.png I, [2013-09-26T10:54:14.011733 #8431] INFO -- : Writing /rails/myapp/releases/20130926175008/public/assets/sort_desc-05521e27371d9dd4e6febce9314bc7ed.png I, [2013-09-26T10:54:14.017370 #8431] INFO -- : Writing /rails/myapp/releases/20130926175008/public/assets/sort_desc_disabled-a3215e17d6bf077db02468b895fee228.png rake aborted! Caught Encoding::CompatibilityError at '["ok","!function(e,t': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (in /rails/myapp/releases/20130926175008/app/assets/javascripts/application.js) /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:242:in `rescue in parse_string' /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:213:in `parse_string' /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:257:in `parse_value' /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:121:in `parse' /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/common.rb:155:in `parse' /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/common.rb:334:in `load' /rails/myapp/shared/bundle/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/external_runtime.rb:62:in `extract_result' /rails/myapp/shared/bundle/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/external_runtime.rb:28:in `block in exec' /rails/myapp/shared/bundle/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/external_runtime.rb:41:in `compile_to_tempfile' /rails/myapp/shared/bundle/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/external_runtime.rb:27:in `exec' /rails/myapp/shared/bundle/ruby/2.0.0/gems/uglifier-2.2.1/lib/uglifier.rb:176:in `really_compile' /rails/myapp/shared/bundle/ruby/2.0.0/gems/uglifier-2.2.1/lib/uglifier.rb:100:in `compile' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/uglifier_compressor.rb:25:in `evaluate' /rails/myapp/shared/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/context.rb:197:in `block in evaluate' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/context.rb:194:in `each' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/context.rb:194:in `evaluate' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/bundled_asset.rb:25:in `initialize' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/base.rb:377:in `new' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/base.rb:377:in `build_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/index.rb:94:in `block in build_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/caching.rb:58:in `cache_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:211:in `block in find_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:257:in `benchmark' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:210:in `find_asset' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:119:in `block in compile' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:118:in `each' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:118:in `compile' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/rake/sprocketstask.rb:146:in `with_logger' /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `call' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `each' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `each' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run' /rails/myapp/shared/bundle/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>' /rails/myapp/shared/bundle/ruby/2.0.0/bin/rake:23:in `load' /rails/myapp/shared/bundle/ruby/2.0.0/bin/rake:23:in `<main>' Tasks: TOP => assets:precompile 

Gemfile (on request):

 source 'https://rubygems.org' ruby '2.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.0' gem 'pg' gem 'sass-rails', '~> 4.0.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 1.2' group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails' gem 'guard-rspec' # gem 'debugger' end group :development do gem 'annotate' gem 'spork-rails', github: 'sporkrb/spork-rails' gem 'guard-spork' gem 'awesome_print' gem 'better_errors' gem 'binding_of_caller' gem 'pry-rails' #substitute pry for irb end group :test do gem 'selenium-webdriver' gem 'capybara' gem 'faker' gem 'database_cleaner' gem 'poltergeist' gem 'launchy' end gem 'rvm-capistrano' #, group: :development gem 'haml-rails' # gem 'zurb-foundation' # gem 'foundicons-rails' gem 'bootstrap-sass', :git => 'git://github.com/thomas-mcdonald/bootstrap-sass.git' #, :branch => '3' gem 'kaminari' gem 'ancestry' gem 'twitter-typeahead-rails' # gem 'bootstrap-typeahead-rails' #TODO gem 'hogan_assets' gem 'awesome_print' gem 'multi_json', '1.7.8' # error in cap deploy with version 1.7.9 # gem 'json' # not necessary before multi_json deploy failure gem 'textacular' gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails' 
+7
debugging ruby-on-rails encoding rake asset-pipeline
source share
2 answers

I would just start the cycle of deleting a file from your manifest, and then try to deploy. If this does not work, I will remove the next file from the manifest and so on until I find the one that causes the problem.

+2
source share

Just having faced a similar problem - received InvalidByteSequenceError during assets: to recompile. I did this - I changed the gem code a bit to โ€œputโ€ some debugging information, in particular, the current file name being processed. Then I pre-compiled again, found the file based on the debug output, and fixed it. Then, of course, I returned the changes to the gemstones. You can use the same approach as you have backtracking. In addition, you could even debug asstes: precompile the task (either with the built-in debugger, or through your favorite IDE. Hope this helps!

+1
source share

All Articles