知道如何修复此错误吗?
assets:precompile
以某种方式在我的本地计算机(mac)上正常工作config.assets.js_compressor = :uglifier
。 (但我想uglify)bower_components/jquery/src/intro.js
中失败(如果我手动修复intro.js中的语法错误,那么得到outro.js的错误)I, [2015-07-10T06:54:41.017580 #21463] INFO -- : Writing /srv/www/app/releases/20150710064958/public/assets/jquery/src/event-53bd66b3ef4e0030febbf883c4ccab1e.js
I, [2015-07-10T06:54:41.034631 #21463] INFO -- : Writing /srv/www/app/releases/20150710064958/public/assets/jquery/src/event/ajax-2728c2aeb59d870e60923e2a75492611.js
I, [2015-07-10T06:54:41.057426 #21463] INFO -- : Writing /srv/www/app/releases/20150710064958/public/assets/jquery/src/event/alias-b8026dcda8af25a845c9aaf6b812a0c3.js
I, [2015-07-10T06:54:41.073036 #21463] INFO -- : Writing /srv/www/app/releases/20150710064958/public/assets/jquery/src/event/support-7331020932640489d80faa12a4510a96.js
I, [2015-07-10T06:54:41.093488 #21463] INFO -- : Writing /srv/www/app/releases/20150710064958/public/assets/jquery/src/exports/amd-4a5f196c0022a5f22de3dd642af82512.js
I, [2015-07-10T06:54:41.131496 #21463] INFO -- : Writing /srv/www/app/releases/20150710064958/public/assets/jquery/src/exports/global-fa942be8ff1d0bcc250cff98e5c45509.js
rake aborted!
ExecJS::ProgramError: Unexpected token: eof (undefined) (line: 46, col: 0, pos: 1394)
Error
at new JS_Parse_Error (<eval>:2357:10736)
at js_error (<eval>:2357:10955)
at croak (<eval>:2357:18667)
at token_error (<eval>:2357:18804)
at unexpected (<eval>:2357:18892)
at block_ (<eval>:2357:23918)
at ctor.body (<eval>:2357:23572)
at function_ (<eval>:2357:23637)
at expr_atom (<eval>:2357:26669)
at maybe_unary (<eval>:2357:29262)
(in /srv/www/app/releases/20150710064958/vendor/assets/bower_components/jquery/src/intro.js)/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:34:in `rescue in block in eval'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:28:in `block in eval'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:80:in `block in lock'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:78:in `call'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:78:in `Locker'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:78:in `lock'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:27:in `eval'
/home/deploy/.bundler/app/ruby/2.0.0/gems/execjs-2.0.1/lib/execjs/ruby_racer_runtime.rb:19:in `exec'
/home/deploy/.bundler/app/ruby/2.0.0/gems/uglifier-2.2.1/lib/uglifier.rb:176:in `really_compile'
/home/deploy/.bundler/app/ruby/2.0.0/gems/uglifier-2.2.1/lib/uglifier.rb:100:in `compile'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/uglifier_compressor.rb:25:in `evaluate'
/home/deploy/.bundler/app/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:197:in `block in evaluate'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `each'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `evaluate'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:25:in `initialize'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:61:in `block (3 levels) in define'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/home/deploy/.bundler/app/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:60:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
---- End output of bundle exec rake assets:precompile ----
Ran bundle exec rake assets:precompile returned 1
[2015-07-10T06:54:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
答案 0 :(得分:0)
我最终使用asset_sync,因为assets:precompile
在我的服务器上无效。
答案 1 :(得分:0)
让我猜一下:你正在使用Capistrano? (这就是我找到这个页面的方式)
在这种情况下(对于那些使用Capistrano的人):当我尝试使用默认配置时,我确实遇到了这个问题。每当我执行cap production deploy:assets:precompile
时,它都会抛出错误。执行bundle exec rake assets:precompile
仍然可以在部署机器上运行(如果手动执行)。
我的修复超越了卡皮斯特拉诺的工作:
Rake::Task["deploy:assets:precompile"].clear_actions
class PrecompileRequired < StandardError; end
namespace :deploy do
namespace :assets do
desc "Precompile assets if changed"
task :precompile do
on roles(:app) do
#invoke 'deploy:assets:precompile_changed'
within release_path do
execute <<-EOCOMMAND
(cd #{release_path}/vendor/assets
bundle exec rake assets:precompile)
EOCOMMAND
end
end
end
end
end
从这一刻起,它奏效了。我的猜测是,Capistrano默认使用不同版本的rake或uglify(也许是全局安装的版本)。