heroku pg:psql "no app specified" - ruby-on-rails

I am trying to access my Heroku database with the usual command heroku pg:psql but I am getting :
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
Although I am running it from the app folder. If I try heroku pg:psql --app APPNAME I get :
Resource not found
Has anything changed recently?

Alright I just needed to update my heroku toolbelt.

Related

How to specify an app's name while running a Heroku command?

I've just run heroku run rails db:migrate to add some new columns to my production tables after git push heroku master but I receive the error
Simons-MBP:gourmet_coffee Simon$ heroku run rake db:migrate
▸ Error: Could not find git remote stagegcl in /Users/Simon/gourmet_coffee
▸ remotes: heroku staging
So it's clearly trying to run on my staging app. How do I change this so it's my production app?
If you have multiple apps for the same project, you can use --app or -a flag to specify the name of the app.
heroku run rails db:migrate --app <the-name-of-your-app>

'You do not have access to the app' when trying to access heroku console

I recently started collaborating in a project on Heroku using Ruby on Rails. I was added as a collaborator and added the remote to my environment. After some development, I pushed some changes and had no problems:
$ git push staging
Where staging is the name of my remote.
Later, when trying to run "rake test" on Heroku, I recieved an error:
$heroku run rake test --app staging
Running `rake test` attached to terminal... failed
! You do not have access to the app staging.
Which is odd, as I was perfectly able to push my own changes. I checked the Heroku dashboard and saw that my push was logged there. I then tried to view the logs using the console, and the same problem occured.
$ heroku logs --app staging
! You do not have access to the app staging.
Finally, I tried to access the console, but it failed as well.
$ heroku run rails console --app staging
Running `rails console` attached to terminal... failed
! You do not have access to the app staging.
At this point I updated my Heroku toolbelt installation, and used "heroku auth" to verify that my email was showing up, but the error persists. I'm currently contacting Heroku support but I'm hoping someone with a similar issue could aid me in parallel.
Thanks!
So just in case anyone is having a similar problem, this occurs because I was mixing the name of my Heroku Apps with the name of my git remotes. So when I was calling --app staging (the name of my remote), I should have been using the actual name of the app, as found in Heroku.
Be sure to run heroku login before using Heroku toolbelt commands for the first time. It will not tell you that you have not signed in before.
This happen also when you haven't added heroku git remote repository.
You can add it with this command:
git remote add heroku https://git.heroku.com/<your project>.git
You can also type
heroku git:remote -a AppName
I had the same problem because I had created multiple remotes on heroku (e.g. a remote called "staging" for staging, and the default remote "heroku" for prod).
Solution
Use these two options to let heroku know which app and remote you're referring to:
-a your_app_name, and
--remote name_of_remote
Examples
For example, for the remote called staging:
heroku run env -a your_app_name --remote staging
or like this for the production remote:
heroku run env -a your_app_name --remote heroku
Extra Info
The above code runs the simple command env, but you can replace that with whatever commands you want to run on heroku.
Replace the name of the remote. By default, heroku creates one remote called heroku, which is typically the production remote. You can get your remotes with the command: git remote.
This was caused of your ssh key is no more permited to access. Make sure your ssh key is same. You can also regenarate your ssh key and add this to heroku.
You can also run:
heroku run rake test --remote staging
Not sure what happens under the hood, but locally the CLI tool figures out which app you mean based on your git remote.
I had the same problem in my case I was not pushing from master so I had to use this:
git push heroku :main
I had the same problem. It was cause I was not login in Heroku.
First I type:
heroku login
then i type:
heroku git:remote -a restserver-node-jngs
and it works.
I hope it be helpfull for someone.

heroku App not found when checking the logs and console but not when running migrations

$ heroku logs --app stormy-headland-566
! App not found.
$ heroku run console --app stormy-headland-566
Running `console` attached to terminal... failed
! App not found
$ heroku list
=== Dev & Legacy Apps
stormy-headland-5660
It's weird because I was able to run the migrations to the app and I was able to push the github repo to the app.

"heroku run rake db:migrate" issue

Folks, I am following Ruby on Rails Tutorial and working on the DemoApp in Chapter 2. My env is :
Win 7
Ruby 1.9.3
Rails 4.0.2
I have deployed the demo app (under directory demo_app) locally and have tested it out locally as well. I did push it to Heroku using
c:\rails_projects\demo_app heroku create --stack cedar
c:\rails_projects\demo_app git push heroku master
the app gets deployed to heroku.
When I run: heroku run rake db:migrate
I get the error:
No app specified. Run this command from an app folder or specify which app to use with --app APP.
I have run it with heroku run rake db:migrate --app demo_app
but get the same error.
Not sure what to do.
Heroku will have given your app a random name when you created the app. Run heroku apps from the terminal to get the name of your app, then heroku run rake db:migrate --app your_app_name.
Assuming the name of your app is robot.
On your terminal, heroku run rake db:migrate --app=robot

heroku : run rake db:migrate error

Running `rake db:migrate` attached to terminal... failed
! Multiple apps in folder and no app specified.
! Specify app with --app APP.
I get the above error in my terminal when I try to run rake db:migrate can anyone please help?
As the error clearly states, you need to specify which app you wish to run the command for. If you are inside of the project directory, you shouldn't need to specify the app. If you are outside of your projects folder run the command like so:
heroku run rake db:migrate --app <your-app-name>
I've had this problem crop up where it wasn't related to heroku at at. If you really want to see, open up your .git/config file
For example, I was with staging and found I had the 2nd remote. Deleting this from my .git/config file fixed everything.
[remote "staging"]
url = git#heroku.com:site-stage.git
fetch = +refs/heads/*:refs/remotes/staging/*

Resources