Heroku command line "--app" extension permission denied - ruby-on-rails

I have remotes to two heroku apps, one for staging and one for production. I am encountering a strange permission denied error when I try to target one of the apps. For example, if I run:
heroku logs --app staging
I get back:
! You do not have access to the app staging.
However, if I simply change the command to:
heroku logs --remote staging
it works fine. Of course this isn't a huge inconvenience, but I would like to be able to use the --app extension without permission issue. If anyone has encountered this before, or has any ideas as to why this may be, please let me know :).
Thanks!

These two options use entirely different mechanisms to lookup the Heroku app by 1) git remote name 2) heroku app name.
When you say --app staging you are looking up an app called staging which you do not own, and getting a permission denied.
When you use the --remote staging you are looking up the app attached to your git remote called staging and it works.
The right way to use --app is with --app your-app-name, since staging is not your app.

Related

How do I get to heroku error pages like on a local server

After deploying my app to heroku i get application error. But i do not get stack trace and any other information in browser. Yeah i know i can use heroky -logs but they don't give me information at all.All Ready try to set up ENV=Development. Want to my error pages on heroku will looks like
try this, you can keep track
heroku logs -t
You can catch errors manually and show they at view
Errors catching in Ruby is perfomes via begin, rescue, else, ensure and end
And you are need not catch errors in each method of each controller - you just can add common handler for unhandled exceptions, look here how
On heroku your app runs in production mode. I beleive, the answer for this question should help: Rails - error in production mode
To see development like errors on Heroku you have to run the app in development mode. Heroku sets two config variables RACK_ENV and RAILS_ENV to production by default when you deploy your app to heroku, you can see this in config vars under heroku app settings.
To run your app in development mode set RACK_ENV and RAILS_ENV to development.
You can do this through heroku toolbelt:
heroku config:set RACK_ENV=development --app app-name
heroku config:set RAILS_ENV=development --app app-name
Not to mention but you should set this back to production before giving it to your real users.

How do I debug an error on Heroku that won't show up in dev or production mode locally?

I have an issue with an app that is doing one thing strangely (or not doing something I expect) only when pushed to Heroku and not in either development or production environments locally.
I tried putting binding.pry in my code, but it simply crashed Heroku.
How do I debug the instance on Heroku where the error is showing up?
Edit 1
I tried viewing my logs from Heroku, by doing heroku logs --tail but those are production environment logs. Not the detailed development logs that I would love to see. Is there anyway for me to retrieve development logs from Heroku to view?
I think your best option is using heroku logs from your app folder.
heroku logs --app appname
and
heroku logs -t --app appname , This is also better option.

Avoid needing to declare "-a" on Heroku

This should probably be a super easy question but I can't figure out what I have not done properly.
I run 5 apps on Heroku, on my first three ones I can use commands as:
git push heroku
whereas the new ones I have to explicitly declare
git push git#heroku.com:myappname.git
For the old ones, if I am in the correct folder on my local app I can use commands such as:
heroku logs
to see the logs of that app on Heroku, whereas with the new ones I have to specify
heroku logs -a myapp
It seems like I have missed something with my git "connection" with Heroku.
What have I missed?
The heroku git repo is not associated with your application, use:
git remote add heroku <repo_name>

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.

cloned project from github. heroku does not work

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

Resources