git push heroku master will not recognize my Gemfile.lock file - ruby-on-rails

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.

Related

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!

Ruby on Rails Heroku - error deploying project

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.

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)

Rails app not recognized by Heroku

I can't push to Heroku and unfortunately none of the other questions on StackOverflow help.
I'm using Rails 3.0.9 and Heroku doesn't recognize my app as a Rails app.
$ git push heroku master
Counting objects: 378, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (311/311), done.
Writing objects: 100% (378/378), 134.64 KiB, done.
Total 378 (delta 143), reused 107 (delta 12)
-----> Heroku receiving push
-----> Removing .DS_Store files
! Heroku push rejected due to an unrecognized error.
! We've been notified, see http://support.heroku.com if the problem persists.
To git#heroku.com:cold-xyz.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:cold-xyz.git'
The repository's layout was wrong.
My rails app was in a subdirectory of the repository. I set Rails' root directory to the repositories root directory and that fixed it:
git mv subdirectory/* .
Try updating your bundle, and then pushing it again.
Or may have something to do with gemlock file?
Else if all fails, you can remove the .git file and re init again.

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