Heroku rake assets:precompile failing - ruby-on-rails

I'm having a hard time diagnosing why the rake assets:precompile function is failing when pushing to heroku.
Here's an excerpt of my failure message:
remote: I, [2015-09-27T23:13:38.130174 #1566] INFO -- : Writing /tmp/build_ece222744980130b2be8b337003ec99c/public/assets/application-c7927379441221ea1d8a9e016fe470ae6acdbe343094861d91f0dade373344d4.js
remote: rake aborted!
remote: Sass::SyntaxError: Invalid CSS after " */": expected "}", was ""
remote: (sass):7791
remote: /tmp/build_ece222744980130b2be8b337003ec99c/vendor/bundle/ruby/2.0.0/gems/sass-3.4.18/lib/sass/scss/parser.rb:1162:in `expected'
Obviously it is failing due to some JS syntax. I have several Javascripts that I used in conjuction with the Signature Pad application, but only edited a few. In an attempt to diagnose, I removed the 'suspect' edited ones and retried my push, to no avail. I also completed the rake assets:precompile command on my local dev machine, which completed without error.
Does anyone have any advice on how I might narrow my search down?

Found my error. I left out a closing } in one of my CSS statements when I added in print media type

Related

Ruby on Rails [heroku] git push heroku master error

I am trying to upload my web app on heroku, but the following error occurs.
(I'm coding with cloud 9 IDE)
$ git push heroku master
.....
remote: -----> Installing node-v10.14.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: Yarn executable was not detected in the system.
remote: Download Yarn at https://yarnpkg.com/en/docs/install
remote: I, [2019-05-22T02:13:47.373334 #1766] INFO -- : Writing
/tmp/build_fcc84922ee6a02bfc05a163c871d0548/public/assets/noimage-
3aa3997354b4e9c37f379deb61626f55ade493078d1b42dcefe4a3ccbed34106.jpg
remote: rake aborted!
remote: ExecJS::RuntimeError: SyntaxError: Unexpected character '`'
remote: JS_Parse_Error.get ((execjs):3538:621)
remote: (execjs):4060:48
remote: (execjs):1:102
.....
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
First of all, It says that "there Yarn executable was not detected in the system", but it is properly downloaded if I check it with yarn -v.
Also, ExecJS :: RuntimeError: SyntaxError: Unexpected character '`' error seems to be that es6 is not recognized, as a solution
config.assets.js_compressor =: uglifier
config.assets.js_compressor = Uglifier.new (harmony: true)
Changed to This seems to be able to read es6. But the above error still persists.
Also, if I run 'rake assets: precompile RAILS_ENV = production' on the console, it runs normally without error.
Thanks.
Try to add this gem in your gem file.
gem 'therubyracer'
Try this link:
Syntax error when deploying Rails app to Heroku: ExecJS::RuntimeError: SyntaxError: Unexpected character
config.assets.js_compressor =: uglifier
=: uglifier
space between : and uglifier?
should be = :uglifier
and try to use precompile command without string RAILS_ENV = production
because Heroku installs production mode by default. if I'm not mistaken
Try this, Go to heroku dashboard on their website, select your app, click on the gear icon (the settings), scroll down until you see “build packs” add ruby and nodejs buildpacks, and make sure the order is that that nodejs comes first in the list, and then ruby (from top to bottom).
If that doesn’t work, can you clarify how you are triggering the compilation of your JS?
Explanation: I’ve seen this error before(with npm, not yarn), essentially you want herokus nodejs buildpack to take care of JS compiling, the one rails has built in seems to not be compatible with their system.

heroku Uglifier::Error: Name expected

After try to deploy a simple rails test app into heroku, in the terminal poped up this
Uglifier::Error: Name expected
in the middle of the assets compilation.
i've searched and i did not find anything related to this, so someone ahs any idea this name expected is about?
remote: I, [2018-04-27T20:10:19.341334 #1686] INFO -- : Writing /tmp/build_171697f13e39a581026e766b205b8f86/public/assets/white-774a5ae6a58216b107623782ce2e1820ebb64f9d294cad32e132c086866f3dd2.png
remote: rake aborted!
remote: Uglifier::Error: Name expected
remote:
/tmp/build_171697f13e39a5810263766b205b8f86/vendor/bundle/ruby/2.3.0/gems/uglifier-4.1.4/lib/uglifier.rb:234:in `parse_result'
Make sure your asset pre-compilation works locally
bundle exec rake assets:precompile
If there are any errors that should help you find where they are happening.
Also see possible duplicate of Heroku Precompiling Assets Failed

Rake Aborted when pushing to Heroku - Errno::ENOENT: No such file or directory #rb_sysopen - /tmp/build/config/application.yml

I am attempting to push to Heroku and am getting the following error:
remote: -----> Detecting rake tasks
remote: sh: 2: Syntax error: Unterminated quoted string
remote: sh: 2: Syntax error: Unterminated quoted string
remote: !
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! rake aborted!
remote: ! Errno::ENOENT: No such file or directory # rb_sysopen - /tmp/build_0ea6e71e6fa31065be1c41a3cb6aaacb/config/application.yml
Running bundle exec rake -P works without any errors.
application.yml is part of my .gitignore, so I'm confused why the error message has to do with this file and why it's preventing me from pushing to Heroku.
Any ideas?
It turned out to be a silly mistake but posting here in case it's useful to anyone else - I was pushing the wrong branch to heroku. Once I corrected the branch name, it worked perfectly.

Heroku error due to an already removed folder

I am trying to deploy Heroku but I still have same error:
rake aborted!
remote: Sass::SyntaxError: Invalid CSS after ".../sass-lang.com/": expected "{", was ""
remote: /tmp/build_fa42ee7d4fc8aec796bb9d2efab757a3/app/assets/stylesheets/todo_tasks.scss:4
I have removed todo_tasks.scss, it is no longer in the app on github but still I have this error,
I tried even installing heroku one more time ^^
What should I do?

Failure to precompile assets when pushing rails app to Heroku

I'm fairly new to rails and web development in general, so maybe I'm forgetting to do something simple, but I've been stuck on this problem for hours. I'm trying to push my rails app to Heroku, and I keep getting a message "Precompiling assets failed". Scrolling up through the console, the only place I really see errors is
Running: rake assets:precompile
remote: I, [2015-06-09T16:33:23.020943 #736] INFO -- : Writing /tmp/build_a3606aeafbcd156e85ce23a261b8ffd5/public/assets/logo-7f005e1459dfe2528e40b953dcc9b0d4.png
remote: PG::UndefinedTable: ERROR: relation "speed_records" does not exist
remote: LINE 1: SELECT "speed_records".* FROM "speed_records"
remote: ^
remote: : SELECT "speed_records".* FROM "speed_records"
remote: rake aborted!
remote: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "speed_records" does not exist
remote: LINE 1: SELECT "speed_records".* FROM "speed_records"
remote: ^
remote: : SELECT "speed_records".* FROM "speed_records"
remote: (in /tmp/build_a3606aeafbcd156e85ce23a261b8ffd5/app/assets/javascripts/googlemaps.js.erb)
remote: /tmp/build_a3606aeafbcd156e85ce23a261b8ffd5/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:822:in `async_exec'
This is a small project that I'm working with others on, and we're all deploying to separate Heroku apps to test our own work as one of the APIs that we're using doesn't work when run on localhost:3000. Other than that, the site runs fine on localhost, but Heroku won't allow me to push to it without errors. Even when I delete everything that I have locally, and clone the master branch from scratch, which is already hosted and working fine on a different Heroku, I still get an error when I try to push it myself. I think part of the issue could be related to the fact that we use the sqlite3 gem for development, but postgres for production, as Heroku requires. However I'm really new to working with databases so I have no idea if that is actually correct or if I'm forgetting to do anything.
Thanks in advance for any help, I've spent hours googling this issue and am completely stumped.
edit: found the solution after spending way too much time on it. The root of the problem seemed to be that I wasn't using "bundle exec" before all my attempted rake commands. From my understanding, this is necessary when the versions of gems you're using for a specific project don't match the versions you've installed system wide.
You need to run migrations. It looks like one of your .js.erb assets is loading some data from a database table that doesn't exist.
You can fix this by running rake db:migrate before you run rake assets:precompile, but you should be aware that your assets will not be dynamically recomputed once precompiled, and whatever data exists in the database at the point of precompilation is the data you'll be stuck using.
I am also faced this type of issue.
Open config/environments/production.rb and make sure the following option is set to true:
then please run
rake assets:precompile --trace RAILS_ENV=production

Resources