3

I saw a similar post in Stackoverflow with a similar error but from what I can tell, it wasn't solved and there seems to be some differences between it and my issue.

Everything (of course) works perfect locally. When pushing to Heroku, though, I get this craziness:

remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        ExecJS::RuntimeError: SyntaxError: Unexpected token punc «{», expected punc «(»
remote:        JS_Parse_Error.Object.defineProperty.get ((execjs):3538:621)
remote:        (execjs):4060:47
remote:        (execjs):1:102
remote:        Object.<anonymous> ((execjs):1:120)
remote:        Module._compile (module.js:456:26)
remote:        Object.Module._extensions..js (module.js:474:10)
remote:        Module.load (module.js:356:32)
remote:        Function.Module._load (module.js:312:12)
remote:        Function.Module.runMain (module.js:497:10)
remote:        startup (node.js:119:16)
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:21:in `eval'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:46:in `call'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/uglifier-3.1.6/lib/uglifier.rb:190:in `run_uglifyjs'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/uglifier-3.1.6/lib/uglifier.rb:152:in `compile'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in `call'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `yield'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote:        /tmp/build_c7ded3066a4d98b445e04f25befe0b17/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed

And it goes on and on. I don't recognize anything in here. My project is very basic - it has no custom .js files or anything yet. Essentially, it is a rails app that has a static pages controller. I don't even know where to begin to look for issues. On a similar post, someone mentioned that they removed the uglifier gem. This didn't change the outcome for me at all.

Any suggestions are appreciated but please understand that I literally know nothing: I need basic step-by-step instructions as though I am a 4 year old. Additionally, I do have a stupid question born out of frustration: Why doesn't it give me an error that actually points to something specifically in the code that I generated rather than all this seemingly auto-generated garbage?

Thanks in advance.

Gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


gem 'rails', '~> 5.0.1'
gem 'bcrypt',         '3.1.11'
gem 'faker',          '1.6.6'
gem 'carrierwave', '~> 1.0'
gem 'mini_magick'
gem 'fog'
gem 'will_paginate',           '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.3.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'puma'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'sqlite3'
  gem 'byebug', platform: :mri
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  gem 'rails-controller-testing', '0.1.1'
  gem 'minitest-reporters',       '1.1.9'
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end

group :production do
  gem 'pg'
  gem 'rails_12factor', '0.0.2'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

application.js:

// 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. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Community
  • 1
  • 1
vicmorrowshead
  • 125
  • 1
  • 9
  • are you running any custom buildpacks? (I noticed this is coming from node startup file) – Bobby Matson Mar 11 '17 at 20:27
  • Also, can you reproduce locally if you run `RAILS_ENV=production rake assets:precompile`? If so, it's likely a collision in your asset pipeline somewhere. – Bobby Matson Mar 11 '17 at 20:28
  • what about exec.js? you have there a syntax error or I misunderstood? it says expected `)` instead of `}` – Fabrizio Bertoglio Mar 12 '17 at 00:01
  • @BobbyMatson I was not running any custom buildpacks at first. One solution from another thread said to run one that would do a purge on deploy. This didn't fix the problem... Although, once the problem was fixed, this buildpack generated an error so I had to remove it. Switching local to build production - problem solved before trying this, but this is definitely something I will keep in mind should this happen again . – vicmorrowshead Mar 12 '17 at 12:58
  • @FabrizioBertoglio exec.js, I think, is generated during the precompilation - it doesn't actually exist anywhere on my system. It seems that the server's precompilation is generating some error in this file.... – vicmorrowshead Mar 12 '17 at 13:00

1 Answers1

4

What ended up solving this problem for me (this time, at least), was to:

  1. precompile the assets locally (rake assets:precompile). This created two files on the local system - think they were gz files).
  2. Commit and push to Heroku. It worked after this.

Although, this explains nothing to me. I have never needed to precompile assets before. And, if it was necessary to do, why did the localhost always work without executing this command? And, Heroku always attempts to precompile the assets. Why did it succeed when I pushed, supposedly, pre-precompiled assets? Doesn't it redo the precompilation anyway?

So, for now, the problem is solved. I have no idea why.

vicmorrowshead
  • 125
  • 1
  • 9
  • 2
    rake assets:precompile works only for development, you will need to use `RAILS_ENV=production bundle exec rake assets:precompile` for production. You did not precompile production, but development, then you pushed development to heroku production. Sometimes old fingerprinted assets are not updated with the modifications you do and you have to precompile to regenerate those fingerprinted application-fingerpint.css and js files – Fabrizio Bertoglio Mar 12 '17 at 13:04