I'm ready to deploy my Rails 3.1 app into production, and since I'm using the asset pipeline, I need to precompile my assets. However, when I try this, I get an error apparently related to compiling jQuery:
$ bundle exec rake --trace assets:precompile
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/adam/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/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 environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
399: unexpected token at '"/*!u000a * jQuery JavaScript Library v1.7.1u000a * http://jquery.com/u000a *u000a * Copyright 2011, John Resigu000a * Dual licensed under the MIT or GPL Version 2 licenses.u000a * http://jquery.org/licenseu000a *u000a * Includes Sizzle.jsu000a * http://sizzlejs.com/u000a * Copyright 2011, The Dojo Foundationu000a * Released under the MIT, BSD, and GPL Licenses.u000a *u000a * Date: Mon Nov 21 21:11:03 2011 -0500u000a */u000afunction addActiveScaffoldPageToHistory(a,b){if(typeof
[snip lots of stuff]
(in /data/music/RotC/eventbook/app/assets/javascripts/application.js)
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/json-1.6.4/lib/json/common.rb:148:in `parse'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/json-1.6.4/lib/json/common.rb:148:in `parse'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/multi_json-1.0.4/lib/multi_json/engines/json_common.rb:9:in `decode'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/multi_json-1.0.4/lib/multi_json.rb:76:in `decode'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:61:in `extract_result'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:27:in `block in exec'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
/home/adam/.rvm/gems/ruby-1.9.3-p0@rails-3.1/gems/execjs-1.2.13/lib/execjs/external_runtime.rb:26:in `exec'
[snip lots more stuff]
Here's my application.js
:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//
// N.B. jQuery requires have to come before this:
//= require active_scaffold
I'm using the default compressor, i.e. uglifier
.
I've found that if I change config.assets.compress
to false
in config/environments/production.rb
then it works fine, but of course my app would perform better if I could figure out a way to keep it as true
.
I've looked at rake assets:precompile doesn't work (rails 3.1.1) and I don't think it's a duplicate because the error is undefined: Unexpected token: operator (<)
.
Any ideas? I'm vaguely suspicious of those unicode characters in the jQuery code, but I'm not sure how to prove or disprove that they are causing the problem.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…