Ruby on Rails Heroku - error deploying project - ruby-on-rails

Recently I tried to push my Rails project to git using Heroku, but the wild problem appeard.
All lines I pasted here: http://pastebin.com/5y09wFCi
Here I paste lines, which I found most important:
$ git push heroku master
Initializing repository, done.
Counting objects: 98, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (89/89), done.
Writing objects: 100% (98/98), 20.04 KiB | 0 bytes/s, done.
Total 98 (delta 8), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.7.12
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/...........
.
.
.
Bundle completed (26.03s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
I, [2015-02-07T17:06:17.823271 #1283] INFO -- : Writing /tmp/build_374afebb598e92eacd894ae2e50e6a4d/public/assets/application-4be62d87c5bb7f3e09992032049b2bd0.js
rake aborted!
wrong number of arguments (2 for 1)
.
.
.
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:stark-tor-4197.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:stark-tor-4197.git'
stark-tor-4197 is my randomly named project.
It may be also important - I read, that Heroku don't work with sqlite3, so I had to make change in my gemfile.
Now part about database looks like this:
http://pastebin.com/EKjFzKDh
# Use postgresql as the database for Active Record
gem 'pg'
gem 'rails_12factor', group: :production
Thanks for any help!

A while ago I also had this problem where the following happened:
git push github master
To git#github.com:Joey-project/project.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:Joey-project/project.git'
I've been told that the most common reason of this happening is because one is trying to push a branch to a remote branch that has been updated in the meantime.
In general one has to use a variation of the following commands:
git fetch github; git merge github/master
Any chance you already looked at RomanKapitonov's question (heroku: Gemfile.lock is required issue)? I believe it's related to your issue.

Try to run rake assets:precompile on your local as it looks like there is some error in your assets i.e. javascript or css files.

Related

Rails 5 Heroku - failed to detect set buildpack

I have a Rails 5 app that I'm trying to push to Heroku. The Heroku instance exists, git remotes are set up, etc. However I'm getting an error that it can't detect the buildpack, although it is defined. Any ideas?
$ heroku buildpacks
=== xx Buildpack URL
heroku/ruby
$ heroku buildpacks:set heroku/ruby
▸ The buildpack heroku/ruby is already set on your app.
$ git push heroku master
Counting objects: 1208, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1075/1075), done.
Writing objects: 100% (1208/1208), 25.04 MiB | 1.63 MiB/s, done.
Total 1208 (delta 634), reused 217 (delta 49)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/ruby.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to xx.
...
If the configured buildpack cannot handle your application (as determined by its detection script), you will receive an error. For example, Heroku’s Ruby buildpack expects a Gemfile to be present in the root folder of an application to correctly identify its type, but if the buildpack of an application is set to heroku/ruby and no Gemfile is present, the application will fail to build. Try check if your Gemfile is present in the root folder of your project.

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 Deploy Error: No Default Language

I am trying to push some ruby code with git and keep getting stopped part way through. Here is my setup and error I get..
root#slacker:~/ruby# git remote -v
heroku https://git.heroku.com/warm-woodland-27175.git (fetch)
heroku https://git.heroku.com/warm-woodland-27175.git (push)
root#slacker:~/ruby# ls
config.ru myapp.rb
root#slacker:~/ruby# git push heroku master
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 398 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to warm-woodland-27175.
remote:
To https://git.heroku.com/warm-woodland-27175.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/warm-woodland- 27175.git'
root#slacker:~/ruby#
I am still trying to understand the ins and outs of git but I am pretty lost as to why git doesn't recognize the file extensions in my compilation folder. I thought that was how it fetched what language to use, .rb .pl etc... Any help would be much appreciated.
I had this error when trying to deploy my Sinatra app to Heroku.
heroku buildpacks:set heroku/ruby
I read https://devcenter.heroku.com/articles/buildpacks which helped me finish the solution.
But I started with https://devcenter.heroku.com/articles/rack
which helped me understand the files that you need to add such as the Gemfile etc. Make sure you do the bundle install.
Make sure you committed your changes after you added the Gemfile, etc. So
git add .
or whatever you need to do it then commit
git commit -m "Added files for Heroku deployment"
or change the message as you want. and then can you deploy using
git push heroku master
Now I have my site running using heroku
If I am missing something that you need, just ask in comments so I can clarify.
I had the same issue when I was trying to deploy to Heroku with Ruby Sinatra. The issue in my case was that I'm brand new to Ruby and Sinatra and didn't know anything about the gems and bundling.
I literally only had my app.rb file in the folder.
I took the following steps, based on some guides 1 I read:
If my app is called app.rb, create a file called config.ru:
require './hello'
run Sinatra::Application
Create a file called Gemfile:
source 'https://rubygems.org'
gem 'sinatra'
Then I found this article that reminded me that I need to run bundle install.
Then I add these files to my git, pushed it, and mine is working!

git push heroku master will not recognize my Gemfile.lock file

My first time pushing to Heroku using Git and I'm getting the error message: Gemfile.lock is required. Please run "bundle install" locally and commit your Gemfile.lock.
I have ran bundle install, added the files to the git repo, commited the changes. See the Gemfile.lock in both the repository and my directory but when I run the command git push heroku master it consistently throws that error.
What am I doing wrong:
Here is the git repo on my PC
$git ls-files
.bundle/config
.gitignore
.rspec
Gemfile
Gemfile.lock
README
Rakefile
app/assets/images/rails.png
app/assets/javascripts/application.js
app/assets/stylesheets/application.css
..<snip>..
Here is the git status of the repo.
$git status
# On branch ch_ruby_intro
# Your branch is ahead of 'origin/ch_ruby_intro' by 6 commits.
#
nothing to commit (working directory clean)
Error when I try to deploy.
$git push heroku master
Counting objects: 239, done.
Compressing objects: 100% (140/140), done.
Writing objects: 100% (239/239), 50.30 KiB, done.
Total 239 (delta 74), reused 215 (delta 67)
-----> Heroku receiving push
-----> Ruby/Rails app detected
!
! Gemfile.lock is required. Please run "bundle install" locally
! and commit your Gemfile.lock.
!
! Heroku push rejected, failed to compile Ruby/rails app
Why is it not seeing the Gemfile.lock file?
Might it be that you're committing to the wrong branch? You're pushing master and committing to ch_ruby_intro.

Invalid path in Heroku

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.

Resources