Reputation: 811
I'm trying to compile my assets in order to put my project into production. When executing this command:
rake assets:precompile --trace RAILS_ENV=production
I get the following error:
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
ExecJS::ProgramError: identifier ' (function(options) {
function comments(option) {
if (Object' undefined
(execjs):1
/usr/local/bundle/gems/execjs-2.6.0/lib/execjs/duktape_runtime.rb:29:in `call_prop'
/usr/local/bundle/gems/execjs-2.6.0/lib/execjs/duktape_runtime.rb:29:in `call'
/usr/local/bundle/gems/uglifier-2.7.2/lib/uglifier.rb:212:in `run_uglifyjs'
/usr/local/bundle/gems/uglifier-2.7.2/lib/uglifier.rb:179:in `compile'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/uglifier_compressor.rb:52:in `call'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:60:in `block in load'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:44:in `load'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `yield'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `load'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/base.rb:66:in `find_asset'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:134:in `block in find'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:133:in `each'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:133:in `find'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:168:in `compile'
/usr/local/bundle/gems/sprockets-rails-3.0.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/usr/local/bundle/gems/sprockets-3.5.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/usr/local/bundle/gems/sprockets-rails-3.0.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/usr/local/bundle/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/usr/local/bundle/bin/rake:16:in `load'
/usr/local/bundle/bin/rake:16:in `<main>'
Duktape::ReferenceError: identifier ' (function(options) {
function comments(option) {
if (Object' undefined
/usr/local/bundle/gems/execjs-2.6.0/lib/execjs/duktape_runtime.rb:29:in `call_prop'
/usr/local/bundle/gems/execjs-2.6.0/lib/execjs/duktape_runtime.rb:29:in `call'
/usr/local/bundle/gems/uglifier-2.7.2/lib/uglifier.rb:212:in `run_uglifyjs'
/usr/local/bundle/gems/uglifier-2.7.2/lib/uglifier.rb:179:in `compile'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/uglifier_compressor.rb:52:in `call'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:60:in `block in load'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/loader.rb:44:in `load'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `yield'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `load'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/base.rb:66:in `find_asset'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:134:in `block in find'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:133:in `each'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:133:in `find'
/usr/local/bundle/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:168:in `compile'
/usr/local/bundle/gems/sprockets-rails-3.0.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/usr/local/bundle/gems/sprockets-3.5.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/usr/local/bundle/gems/sprockets-rails-3.0.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/bundle/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/usr/local/bundle/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/usr/local/bundle/bin/rake:16:in `load'
/usr/local/bundle/bin/rake:16:in `<main>'
Tasks: TOP => assets:precompile
Whats happening? Am I compiling assets in the right way?
this my Javascript within the comments:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require ckeditor/init
//= require_tree .
this is the error when open the page in the browser:
(index):21 GET http://dev.nutrimais.com.br/assets/application-c69ac193f2f610776253a81e6da332ce0bb1141cac0141b0d50c686d872126a5.css
application-541957df4066a1b6e019883423b470301accf44038125390a3908dcf374e1a2b.js:1 Uncaught Error: ExecJS::ProgramError: identifier ' (function(options) {
function comments(option) {
if (Object' undefined
(in (execjs):1)(anonymous function) @ application-541957df4066a1b6e019883423b470301accf44038125390a3908dcf374e1a2b.js:1
(index):54 Uncaught ReferenceError: $ is not defined(anonymous function) @ (index):54
(index):151 Uncaught ReferenceError: $ is not defined
Just discovered that if I use rake assets:precompile --trace it compiles. But using the rake assets:precompile --trace RAILS_ENV=production it gives me the errors
Upvotes: 1
Views: 458
Reputation: 61
Put it in your gemfile:
group :production do
gem 'therubyracer'
end
Upvotes: 1
Reputation: 479
You have a bug in your Javascript within the comments function. Fix that and the app will compile! Im happy to take a look if you can post that function.
Upvotes: 1