Push to Heroku being rejected - ruby-on-rails

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

Related

Precompiling assets failed after adding action text

I tried adding action text by following this: https://stackoverflow.com/a/55983943.
Everything worked fine in development.
But when I try to push it to heroku by running git push heroku, I get this error:
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 sampleapp.
remote:
remote:
To https://git.heroku.com/sampleapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/sampleapp.git'
I tried adding
config.assets.initialize_on_precompile = false
to config/application.rb but it didn't work
Its already added to config/environments/production.rb.
I tried running RAILS_ENV=production bundle exec rake assets:precompile
but it gave me this error:
ExecJS::RuntimeError: SyntaxError: Unexpected token: string (actiontext)
JS_Parse_Error.get ((execjs):3538:621)
So, how do I resolve this error?
This probably sounds dumb but I solved the problem now.
What worked was changing
config.assets.js_compressor = :uglifier
in config/environments/production.rb to
config.assets.js_compressor = Uglifier.new(harmony: true)

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.

Deploy ember-cli-rails 5 app to Heroku - failed to compile ruby app

I'm following this thoughtbot ember-cli-rails guide but cannot get the heroku deploy working. I did have to change bin/heroku_install to remove the lines about bower, and other than that, this is following the setup guide.
I don't see any visible errors in the heroku output so I'm at a loss as to where to go next:
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 enigmatic-savannah-87434.
remote:
To https://git.heroku.com/enigmatic-savannah-87434.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/enigmatic-savannah-87434.git'
The entire deploy log is here if you have the time and will to have a look. Thanks in advance
My next idea is try the sample app, deploying that, and comparing the two projects to see what I may have added that isn't playing nice. Will report back how that goes...

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.

Heroku push rejected - Slug compilation failed: failed to compile Ruby app

It would be really helpful if someone could tell me how to proceed on this. I am following the steps in the below link to deploy the app mentioned in this link.
http://installfest.railsbridge.org/installfest/deploy_a_rails_app
However, the deployment is failing with an error message :
remote: Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: NameError: undefined local variable or method `hRails' for main:Object
remote: Tasks: TOP => environment
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 desolate-peak-2535.
remote:
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/desolate-peak-2535.git'
Here is the server log:
015-08-20T07:54:20.729142+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
015-08-20T08:21:44.563972+00:00 heroku[slug-compiler]: Slug compilation started
015-08-20T08:21:44.563994+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
015-08-20T08:26:26.742224+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
015-08-20T08:26:26.742136+00:00 heroku[slug-compiler]: Slug compilation started
You should be able to reproduce this locally by running rake assets:precompile. Line 3 of your error log. Then the error clearly says this failed, where it says: Precompiling assets failed. And finally, somewhere you are using the variable hRails which is not found. Likely a typo and you mean Rails. Search your project for hRails and that will be where the error is.

Resources