Heroku rejects my git push request - ruby-on-rails

So I created a Rails 4 app and was able to push it upstream to Heroku properly the first time. Every since then I haven't been regularly pushing my changes. I just got to a very significant checkpoint and decided to try to push my changes to the actual site on heroku but it rejects my request saying that it failed to compile my Ruby app. I've copy and pasted some of the feedback my command line provided me with in hopes that someone has had a similar error and can give me some ideas as to what might be wrong. Thanks in advance.
Running: rake assets:precompile
rake aborted!
ExecJS::ProgramError: Unexpected token name «users», expected punc «,» (line: 11341, col: 35, pos: 318042)
Error
at new JS_Parse_Error (/tmp/execjs20140625-619-93tzcv.js:2357:10754)
at js_error (/tmp/execjs20140625-619-93tzcv.js:2357:10973)
at croak (/tmp/execjs20140625-619-93tzcv.js:2357:19198)
at token_error (/tmp/execjs20140625-619-93tzcv.js:2357:19335)
at expect_token (/tmp/execjs20140625-619-93tzcv.js:2357:19558)
at expect (/tmp/execjs20140625-619-93tzcv.js:2357:19696)
at expr_list (/tmp/execjs20140625-619-93tzcv.js:2357:27763)
at /tmp/execjs20140625-619-93tzcv.js:2357:29817
at /tmp/execjs20140625-619-93tzcv.js:2357:27576
at /tmp/execjs20140625-619-93tzcv.js:2357:30108
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app
To git#heroku.com:picritique.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:picritique.git'

A similar error occurred to me recently when deploying a rails 4 app on heroku, and what I did was to precompile the assets in my local machine and then send them to heroku.
Try to do in your local:
rake assets:precompile
git add .
git commit -m 'assets precompiled locally'
git push heroku master
And it worked. I haven't figured the reason yet to do this, so any insight on this will be appreciated. It just worked for me in this way.

Seems like maybe you've got an error in your JavaScript. Are you able to run RAILS_ENV=production rake assets:precompile --trace locally?

I was making mistake in code as below
_companyService.get({companyId },function(result) {...
Fixed it as
_companyService.get({ companyId: companyId },function(result) {...

Related

git push heroku master is rejected and faild to compile ruby app

Did some research but can't figure out what caused the rejection when I tried to git push heroku master.
Here is my the git repo: https://github.com/leonahu/IMGfeed
and this is the details of the rejection:
remote: Tasks: TOP => environment
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
remote: Verifying deploy...
remote:
remote: ! Push rejected to feedimg.
remote:
The error says that the assets failed to precompile, so you should precompile them by running bundle exec rake assets:precompile
Or specifically for production run RAILS_ENV=production bundle exec rake assets:precompile
Make sure that you have this line of code in your config/application.rb file: config.assets.initialize_on_precompile = false
After this, try to push to heroku again
I think you might forget to set config.secret_key_base in production. Run:
heroku config:set SECRET_KEY_BASE=your_secret_key_base
To get a new secret key you can run bundle exec rake secret in the project's root folder.
I tried all the suggestions above but it did not work on my app ( Thanks everyone who tried to help nevertheless.)
What ended up working for me is I basically forced the Heroku by running:
git push heroku master --force
After that, I was able to git push heroku master again.

Push to Heroku being rejected

I have created a simple site built on RoR. I've created a Git repository and have tried to deploy to Heroku but it keeps failing:
remote: rake aborted!
remote: ExecJS::ProgramError: Unexpected character '#' (line: 10848, col: 0, pos: 303135)
remote: Error
remote: at new JS_Parse_Error (/tmp/execjs20151027-1005-1i4h7l5js:2359:10623)
remote: at js_error (/tmp/execjs20151027-1005-1i4h7l5js:2359:10842)
(made a break in the errors for brevity)
remote: Tasks: TOP => assets:precompile
remote: (See full trace by running task with --trace)
remote: !
remote: ! Precompiling assets failed.
remote: !
remote:
remote: ! Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy....
remote:
remote: ! Push rejected to serene-depths-4806.
remote:
To https://git.heroku.com/serene-depths-4806.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/serene-depths-4806.git'
Is it saying that there is a '#' that shouldn't be there? I'm not sure how to find that even though the line is given.
Also, I had changed from sqlite to postgresql and made the changes in the gemfile and database.yml file. I then deleted the old Heroku remote branch and followed these instructions to try and deploy: https://devcenter.heroku.com/articles/git#deploying-code
Any advice is appreciated!
Ah, of course after writing that post, I found the answer (for those who might have the same issue in the future):
It's because the '#' error was in a .js file I had converted from the automated coffeescript files. Doh! I just deleted the commentary at the top of the file and it deployed.
This could be the result of assets precompilation failed and prevents the heroku deployment process.
You can try compiling assets locally to inspect the the error
RAILS_ENV=production bundle exec rake assets:precompile --trace

Error pushing Rails application to Heroku

I'm doing an application in RoR from Linux/Ubuntu and deploying in Heroku but when I try to push to Heroku I get this error:
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app
To git#heroku.com:herokuangelapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:herokuangelapp.git'
Thanks for your help.
Precompilation
Without knowing the exact error, the question arises as to what the error itself is saying. The problem you have is Heroku's precompilation system won't be able to precompile the assets for your Rails application (obviously)
The causes of this could be numerous, but the main culprit is that you have syntax errors in your asset files, preventing them from being precompiled.
--
Local
As recommended in the comments, you should precompile the assets locally using the following command:
$ rake assets:precompile RAILS_ENV=production
This will run the precompilation process on your local machine, and will return any exceptions that occur throughout the process.
In order to get it working, you need to clean up any of the syntax errors which are returned with this local precompilation process

Getting Error while pushing into Heroku (Precompiling assets failed.)

Note: I am using Rails 3.2.13 and Ruby "1.9.3", and postgres-0.15.1
I tried to push my Ruby on Rails app in to heroku by following the procedure this website
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-deploying
, but I got error while try to push into heroku
Connecting to database specified by DATABASE_URL
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
! Precompiling assets failed.
! Push rejected, failed to compile Ruby app
To git#heroku.com:pure-hamlet-9148.git
! [remote rejected] master -> master (pre-receive hook declined)
So, I Googled myself and run the below command
heroku labs:disable user-env-compile
heroku labs:enable user-env-compile
Still getting the same error, please some help me to resolve this issue.
Along with Simone's answer,
Follow this website to precompile your assets locally before deploying. https://devcenter.heroku.com/articles/rails-asset-pipeline
RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets -f
git commit -m "vendor compiled assets"
Check this article about Heroku and Rails asset:precompile error. You should set
config.assets.initialize_on_precompile = false
A way to resolve this error:
First of all set DATABASE_URL environment variable & then again tried to push code to Heroku again. And it worked as all rake compilation done at Heroku side so no more connection to local machine making rake compilation # .../tmp/bin..... directory.

Ruby on Rails Precompiling assets failed

I've been following the reInteractive ruby on rails (15 min blog), and in the end of the post (second part), I got an error using heroku to upload my files:
! Precompiling assests failed
!Push rejected, failed to compile Ruby app
To git#heroku.com:peaceful-sea-8032.git
! [remote rejected] master -> master <pre-receive hook declined>
error: failed to push some refs to 'git#heroku.com:peaceful-sea-8032.git'
ps: The app runs fine on localhost, I saw some similar question but I did not have success trying their solutions.
Precompile your assets locally. In your shell cd to your application folder and enter:
RAILS_ENV=production bundle exec rake assets:precompile
This will precompile your assets locally
Then you have to
git add .
git commit -am 'precompiled assets'
git push heroku
(eddited last line)

Resources