0

I have searched for hours for a solution to this issue with no avail. I can't seem to be able to fix this.

*cap production deploy * throws the following error as shown in the log. This solution doesn't help.

    Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@xxx.xxx.xx.xxx: rake exit status: 1
rake stdout: rake aborted!
JSON::GeneratorError: source sequence is illegal/malformed utf-8
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/json-1.8.3/lib/json/common.rb:223:in `generate'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/json-1.8.3/lib/json/common.rb:223:in `generate'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:46:in `call'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:212:in `run_uglifyjs'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:179:in `compile'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/uglifier_compressor.rb:52:in `call'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/uglifier_compressor.rb:28:in `call'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:60:in `block in load'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:44:in `load'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:47:in `yield'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:47:in `load'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/base.rb:66:in `find_asset'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:138:in `block in find'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/path_utils.rb:204:in `each'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/path_utils.rb:204:in `stat_directory'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/path_utils.rb:222:in `stat_tree'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/legacy.rb:105:in `each'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/legacy.rb:104:in `each'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/legacy.rb:104:in `logical_paths'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:136:in `find'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:162:in `compile'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-3.4.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/var/www/html/app/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
rake stderr: Nothing written


  [1]: https://stackoverflow.com/questions/31372478/rake-aborted-jsongeneratorerror-source-sequence-is-illegal-malformed-utf-8-a

I am patiently waiting on a solution

Community
  • 1
  • 1
Esseme
  • 179
  • 1
  • 12
  • Do you get the same error if you run bundle exec take assets:precompile locally? – will_in_wi Mar 24 '16 at 11:01
  • @will_in_wi calling `bundle exec rake assets:precompile RAILS_ENV=production` locally brings up the same error. calling `bundle exec rake assets:precompile RAILS_ENV=development` locally brings up nothing – Esseme Mar 24 '16 at 13:56

1 Answers1

0

One of the JS files being compiled contains invalid UTF-8 bytes. I don't know which one, but the way I would suggest you debug it is to locally edit the equivalent path to /var/www/html/app/shared/bundle/ruby/2.2.0/gems/json-1.8.3/lib/json/common.rb:223:ingenerate'` to wrap the breaking call in a block like:

begin
  # Whatever normally goes here.
rescue JSON::GeneratorError
  puts whateverliststhefilename
end

If you are already using this, you can also just drop in binding.pry instead of puts.

Once you know the filename, run it through UTF-8 validators like the one you saw in the linked SO answer, and fix it. If the JS is in a gem, try restoring the gem to a pristine condition. If the JS is in your project, fix it accordingly.

You can use http://guides.rubygems.org/command-reference/#gem-pristine to restore a modified or corrupted gem. Be sure to remove your debugging code from the gem file when you are done.

This is more of a teach how to fish answer than a "this is what is wrong and how to fix it" answer. Sorry about that, but there is no way for us to do this unless it is a commonly known issue in a gem, which a Google search would have brought up, or if we have the entire source code.

Hope this helps!

will_in_wi
  • 2,623
  • 1
  • 16
  • 21
  • thanks for the timely response..let me get working. I will be letting you know about how your deliberation goes – Esseme Mar 24 '16 at 14:34