9

我有点绝望;几天来一直试图调试这个问题。任何人都知道如何排除故障?也许确定造成编码问题的文件?

FWIW:这适用于开发环境:RAILS_ENV=production bundle exec rake assets:precompile --trace

但这在“生产”服务器上失败了......不知道如何开始故障排除:

$ 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(根据要求):

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'
4

2 回答 2

2

我将开始一个从清单中删除文件的循环,然后尝试部署。如果这不起作用,我将从清单中删除下一个文件,依此类推,直到找到导致问题的文件。

于 2013-09-27T03:20:31.973 回答
1

刚刚遇到类似的问题 - 在 assets:precompile 期间遇到 InvalidByteSequenceError。我所做的是 - 我稍微编辑了 sprockets gem 代码以“放置”一些调试信息,特别是正在处理的当前文件名。然后我再次运行预编译,根据调试输出找到文件,并修复它。然后我当然恢复了宝石更改。您可以使用相同的方法,因为您有回溯。此外,您甚至可以调试 asstes:precompile 任务(通过内联调试器或通过您最喜欢的 IDE。希望这会有所帮助!

于 2016-06-29T12:41:05.467 回答