cloned project from github. heroku does not work - ruby-on-rails

I cloned a project from github over to my desktop. I used to work on it form my laptop.
However, on laptop heroku does not seem to work for this app eventhough i have it installed.
First problem:
heroku open
>No app specified.
>Run this command from app folder or set it adding --app <app name>
I did not have to specify the --app on my laptop. Because I guess I did command heroku create initially on the lapop.
Second Probelm:
git push heroku master
gives errors
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
and heroku list
says
! This version of the heroku gem has been deprecated.
! Please update it by running: gem update heroku

First do:
git remote add heroku git#heroku.com:{my-project-name}.git
Where you replace {my-project-name} with the name of the Heroku application as it appears in your Heroku account. For example, if your Heroku account says you have an application named flowing-water-397, then the line would be:
git remote add heroku git#heroku.com:flowing-water-397.git
Then Git and the Heroku gem will know that this Git repo is connected to a Heroku.com application. Then you can do things such as:
git push heroku master
heroku open
Finally, learn a little bit more about Git Remotes.

In addition to the git remote add ... that #Justice mentioned, I also needed to run
git config heroku.remote heroku
(solution found here)

I believe I get the error No app specified. Run this command from an app folder or specify which app to use with --app when I run any ambiguous heroku commands. Example:
heroku logs
It's ambiguous because I have multiple remote repositories specified in my project's .git/config file. The solution for me is simply to specify the remote repository. Example:
heroku logs --remote staging
In the above line --remote staging corresponds to the following in my project's .git/config file:
[remote "staging"]
url = git#heroku.accountname:foo-bar-1234.git
fetch = +refs/heads/*:refs/remotes/staging/*
I hope this helps you.. if not, then perhaps it may help someone else!

When I had this issue it was because I created more than one remote app on heroku.
To remove an existing remote app from heroku use:
git remote rm heroku
then go back and use heroku create to start the process over using the correct app name heroku gives you.
Solution found here:
solution

Related

Heroku thinks app is in same folder

I referenced this awesome thread from the following to fork my Heroku app and clone the github repo to have two seperate github repo's and Heroku app's for production and development.
Trying to heroku git:clone after heroku fork yields an empty repository
$ git clone git#heroku.com:oldapp.git -o old newclonedapp
$ cd newclonedapp
$ heroku git:remote -a newclonedapp
$ git push heroku master
I then manually moved my folder newcloneapp into its own directory. Regardless, I still get the following errors:
! Multiple apps in folder and no app specified.
! Specify app with --app APP.
How can I fix this ?
As the error message says, include --app newcloneapp in the command you are running to ensure it works with the right heroku application.
By copying the newcloneapp folder into its own directory, you are still retaining the git config for the application; hence the multiple heroku apps in this folder.
You can remove one of the applications by editing the .git/config file and removing one section with the url = git#heroku.com:your-app-name.git line.
In one of my heroku apps, I have the following config in the .git/config file:
[remote "staging"]
url = git#heroku.com:my-app-name.git
fetch = +refs/heads/*:refs/remotes/staging/*
[remote "production"]
url = git#heroku.com:my-app-name.git
fetch = +refs/heads/*:refs/remotes/staging/*
With this in place, I can push to both staging and production from the same repo. Looks like you need only one app in the folder; so you should have only one of the above sections.

Error pushing to Heroku after adding new domain

I recently added a new GoDaddy domain to my rails app.
Everything works fine when I push to git but when I try to push to Heroku using:
$ git push heroku
I get the following error:
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.
Is this problem occurring because I need to create another environment? The domain name for my GoDaddy website is listed under '$ heroku domains' but doesn't seem to be connected.
Any ideas would be helpful. TIA!
As for your comment on answer below, its obvious that you should try
git push prod master instead of git push heroku
'heroku' and 'prod' it's just names of remote repositories. Heroku by default creates repos named accordingly - 'heroku'. As far as I know it could be changed to whatever you need
This issue is probably unrelated to godaddy. Try typing
git remote -v
this will give you a list of the remote repositories you have setup. If none are pointing to your app on heroku you'll need to set it up.
Refer to this on article from heroku dev center
https://devcenter.heroku.com/articles/git
EDIT
As i suspected your heroku remote is named "prod" not "heroku" try 'git push prod' that should work.
You might have to specify the branch in which case the command would be 'git push prod master'
EDIT2
It looks your are not yet authorized to push to heroku. The root problem can vary. I recommend starting with this article:
https://devcenter.heroku.com/articles/keys
Also check this SO article
git push heroku master Write failed: Connection reset by peer

How to access Heroku from command line if directory has been deleted

A little while ago the files on my Macbook Pro were deleted by Apple, including a directory from which I used to access Heroku and be able to do command line operations in the Ruby/Rails console. Now that the directory is gone, I'm not sure if it's possible to access this repository from the command line, which I need to do to reduce the size of my database to stay within Heroku limits.
Update
before the directory was deleted on my mac, I used to simply cd into that directory and then run something like bundle exec heroku run console or heroku run bundle exec console, anyways if I did it from that directory heroku knew which application i was trying to access and it would take me into the rails console for it (where I could manipulate data)
Install the Heroku toolbelt (it's unclear whether you still have that)
From the terminal, perform a heroku login to authenticate
From a directory where you want the new app to live, run heroku git:clone APP-NAME
You'll now have a directory, which will have the latest files you pushed to Heroku - which will allow you to do things like git push heroku master, or heroku run rails console.
You probably want to then also attach your git repo where you are storing your source code with something like git remote add origin git#github.com:whoyouare/app-name.git
From the Heroku docs:
You can also take an existing Git repo and add a remote using the git URL provided when you created your app. You may need to do this to associate a Git repo with an existing application. The heroku git:remote command will add this remote for you based on your applications git url.
$ heroku git:remote -a falling-wind-1624
This will add your Heroku repo with the remote name of heroku to your working directory.

How to reset everything Heroku in my Git/Rails 3.1 Project

I solved my problem while writing this post, but I thought this might be good information for other noobs like me :)
To solve the problem below edit the following file
.git/config
There's a section that looks like this
[remote "heroku"]
url = git#heroku.com:adjective-noun-1234.git
fetch = +refs/heads/*:refs/remotes/heroku/*
This is what git tries to push to. Just change the line
url = git#heroku.com:adjective-noun-1234.git
to whatever new Heroku project you created. Git should now be able to push to Heroku again.
I have gotten my second Rails app ever to a working state and want to deploy it. So I followed all the steps for Heroku deployment in the Ruby on Rails Tutorial (I had the deployment working for the sample app from the book) using:
heroku create
I then push my project with
git push heroku master
The project doesn't work although I can't find any errors in the Heroku logs, all I get is:
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it
shortly.
So I looked around the Heroku Support Section and found the official Rails 3.0 / 3.1 deployment guide:
http://devcenter.heroku.com/articles/rails3
http://devcenter.heroku.com/articles/rails31_heroku_cedar
I went to the Heroku Web Frontend > General Info > Destroy App because I wanted to continue my efforts with a clean slate.
Following the guide I created a Heroku project for the cedar stack:
heroku create --stack cedar
And push it to Heroku using
git push heroku master
THE PROBLEM: for some reason git is still trying to push to the old Heroku project!!!
resulting in an error
fatal: The remote end hung up unexpectedly
Check your remote repositories, and update it to the new heroku name:
git remote -v
Then remove the heroku one that is wrong:
git remote rm heroku
Then add the new one
git remote add heroku git#heroku.com:sitename.git
This is a bit extreme, but worked for me....
heroku destroy appname
heroku create
git push heroku master

Using external hard drive, heroku 2.4.0 commands are not working

I've configured the keys to my heroku, and I've gotten far enough to be able to commit and push onto my heroku server. But for some reason, commands like "heroku logs" or "heroku rake" or "heroku restart" bring up "no such file or directory" errors. Similarly, heroku restart -app "" bring up an "app not found!" even though I'd typed everything correctly.
I think this may have to do with my Github repo being stored and written on an external hard drive. Is this possible?
Thanks in advance!
An external hard drive will have nothing to do with this problem.
Make sure you are in your app.
cd myap
Then you need to create a repo and add your project to it:
git init
git add.
git commit -m 'master'
Then you need to create a heroku project:
heroku create
heroku rename myapp
git push heroku master
Make sure you have done all of that in that order.
Are you sure you are in the project folder that your application lives in. It doesn't matter where the project is as git and the project git config (including remotes) will all be local to the project folder iteself.
Also, you don't actually need to be in the project folder if you explicitly pass the application name,
eg;
heroku rake db:migrate --app myappnamehere
This also arises if you don't have your heroku remote not named heroku. Eg, I typically call my heroku remotes based off the environment eg, production, development. So my typical push looks like;
git push production mybranch:master
In this scenario when you issue a heroku command it is unable to locate the application name which is does by inspecting the git config for a 'heroku' remote so it will always say application not specified which is why you then need to pass it in explicitly via --app attribute.

Resources