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)
Related
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.
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
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) {...
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.
Everytime I try to deploy my rails app onto heroku it says
Michael$ heroku create
Creating stormy-window-812..... done, stack is bamboo-mri-1.9.2
http://stormy-window-812.heroku.com/ | git#heroku.com:stormy-window-812.git
Michael$ git push heroku master
! Invalid path.
! Syntax is: git#heroku.com:.git where is your app's name
fatal: The remote end hung up unexpectedly
I'm not sure what's wrong. I do a normal heroku create and my git is working for github to load code. Is there something I'm missing? The path seems to be the right format so I don't know that the problem is.
Your .git/config is borked.
Ensure that the remote for heroku points to:
git#heroku.com:stormy-window-812.git
There must be a bit of misstep somewhere in your process, I created a sample app, using the following commands - hopefully this will help you identify where things aren't going right.
Just the list of commands:
$ rails new sample_app
$ cd sample_app/
$ git init
$ git add .
$ git commit -m "Initial commit"
$ heroku create
$ git push heroku master
$ heroku open
And the commands, with some truncated output:
$ rails new sample_app
create
create README
create Rakefile
create config.ru
create .gitignore
# ..snip..
$ cd sample_app/
$ git init
Initialized empty Git repository in /sample_app/.git/
$ git add .
$ git commit -m "Initial commit"
[master (root-commit) 487a313] Initial commit
37 files changed, 1138 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
create mode 100644 README
# ..snip..
$ heroku create
$ git push heroku master
Counting objects: 63, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (47/47), done.
Writing objects: 100% (63/63), 24.81 KiB, done.
Total 63 (delta 2), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for http://rubygems.org/
Installing rake (0.9.2)
Installing multi_json (1.0.3)
Installing activesupport (3.1.0.rc6)
# ..snip..
-----> Compiled slug size is 5.6MB
-----> Launching... done, v4
http://gentle-water-874.heroku.com deployed to Heroku
To git#heroku.com:gentle-water-874.git
* [new branch] master -> master
$ heroku open
I think you need to cd into your app directory. Then do the push again.
Also, make sure you add heroku as your remote then you can try again:
git remote add heroku git#heroku.com:appname.git
I had this problem after renaming my app. If you do
heroku rename newname
you will then have to do
git remote rm heroku
git remote add heroku git#heroku.com:newname.git
My .git/config was clearly dorked - I attempted changing to first_app as shown above (newby: RoR Tutorial chapter 1) several times. Deleting the /.git/config and doing the steps above starting with 'git init' fixed the config: url = git#heroku.com:dry-eyrie-8108.git
It also be as simple as:
$ heroku login
$ heroku git:clone -a appname ( this line right here solved it for me)
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Not sure if anyone else has ran into this same misunderstanding. The error from heroku mentions the url to your app needs to meet this syntax, "https://git.heroku.com/my-app.git".
This did not work for me. However, the syntax, "my-app.herokuapp.com", resolved the error.