How to see files and file structure on a deployed Heroku app - bash

My client app that is deployed on Heroku allows the user to upload images onto Heroku. I wanted to test out a change I made to delete images, so I need a way to see the state of the folder structure on Heroku to ensure the images are being deleted successfully of the file system.
I tried -
$ heroku run bash --app <appName>
~$ pwd
~$ cd <path to images folder>
but I only see images here that I uploaded along with the app, not what was uploaded through the client app.
What am I doing wrong?

I can do with this commands
heroku login
heroku run bash -a APPNAME
$ cd app
APPNAME is the name of your Heroku application And in the folder app are your files.
When you finish your commands and want to return to your terminal you can write
$ exit

Terminal access is now provided by clicking a link "More" on the top right of the Heroku dashboard where you can select "run console".
This presents an option to run terminal commands and shows a default of 'bash'. However, you do have to explicitly enter 'bash' or other command.
If you edit files, you will have to manage synchronization back to your development code using Git.

As in #Juliano Araújo's answer but from a project folder connected via git you can just run
heroku run bash

You can do this with,
heroku run bash -a APPNAME
If the above command fails,
heroku run sh -a APPNAME

`
app settings option gives our files url
`
Then use git clone
git clone https://git.heroku.com/your_app_name.git

So none of the above worked for me on windows and couldn't access my files so I decided to just clone the git repo.
git clone <git-url>

Related

using deploy terminal heroku from file to server

problem on the photo.
when i use the git push heroku master terminal allways give me this response.
i search on google but i didn't find any qestion on my language.
i follow all codes but i see this.
heroku login
$ cd my-project/
$ git init
$ heroku git:remote -a afbchatapp
and
$ git add .
$ git commit -am "make it better"
$ git push heroku master
enter code here
What language are you using?
Let's start with the problem at the beginning. Usually, Heroku tries to automatically detect the type of app you deploy by looking for certain files that act as signatures for the language you're using. So for example if it's a NodeJS app and you're deploying from Github, Heroku will look for the package.json file in the main branch. You can find the rest of the information for other files here. You may want to look at this first.
From there this solution to an almost similar problem should be able to fix the push.

What could be the reason why "heroku open" command is not working?

I have successfully deployed a django app on heroku using this guide. The heroku cli is installed as a snap application on my system - I'm running Fedora 32 on a Dell xps 15 - and everything seems to be working fine except when I try to run the app locally.
When I attempt to run the app locally, I get the following error:
$ heroku open
▸ Error opening web browser.
▸ Error: Exited with code 4
▸
▸ Manually visit https://[myapp].herokuapp.com/ in your browser.
I tried variations of the command to no avail:
$ heroku open -a [myapp]
$ heroku open -r https://git.heroku.com/[myapp].git
When, instead, I run it with heroku local it runs without any problems.
I look at the logs but couldn't find any clues. Neither was I able to find any useful information.
What am I missing?
Try setting the browser in your ~/.bashrc using export BROWSER=
If someone uses Windows Subsystem for Linux, set the BROWSER environment variable in the corresponding shell configuration file (e.g., ~/.zshrc) to wslview.
export BROWSER=wslview

Push From Git Bash to Heroku

I want to push a project I created to Heroku from Git. I'm running windows and have the Git Bash shell installed as well as the Heroku CLI. Running this from Git Bash shows my Git version:
$ git --version
git version 2.14.1.windows.1
However, when I try from that same Git Bash shell to create my application on Heroku as a remote Git repo, I get an error:
$ heroku create
bash: heroku: command not found
So instead I created my application on Heroku from a regular windows cmd terminal and that worked (i.e., when I log into heroku I see the remote repo). But when I try to do a git push from the windows cmd terminal it does not recognize git:
C:\myapp>git push heroku master
'git' is not recognized as an internal or external command,
operable program or batch file.
Whereas when I try to do a git push from the git bash shell, I get this error indicating perhaps it doesn't know what to make of heroku:
$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
So it seems my regular windows cmd terminal recognizes heroku, but my Git bash terminal does not. How do I configure Git bash to recognize the Heroku command?
Note: When I do a env | grep path from the Git bash shell the results do include my C:/Program Files/Heroku/bin directory, so Git is aware of my Heroku path.
Your problem is not that git would not push to heroku, but that you actually haven't installed git on your system, as the message you posted suggests.
'git' is not recognized as an internal or external command,
operable program or batch file.
At heroku's documentation there is a whole article about pushing to git, if you experience further problems after installing git, you might find a solution there.
Found a solution! It required the following 3 steps/considerations:
First, I followed john g's answer here, which is to close Git Bash and login to Heroku via a windows cmd terminal, then use Git Bash as per normal.
Second, when issuing a heroku command from Git Bash on Windows, include the extension, as described here. I.e., issue heroku.cmd create (instead of just heroku create).
Third, apparently the git push heroku master command must be issued from the same Git Bash terminal where you just issued heroku.cmd create. When I had issued it from a separate terminal I got an error saying "'heroku' does not appear to be a git repository".
I'm posting this, in hopes that it may help others and save them the same trouble I had. This was driving me mad and I tried every solution I could manage to find on the issue. Spent several hours trying to trouble-shoot it. What it actually ended up being was a conflict with my internet security, specifically Comodo Internet Security Premium 10. I received no warning, it just automatically added it to a blocked list on first execution. If you are running internet security software, especially on a Windows machine, this very well could be your issue. Remove the command file found at C:\Users\YOUR_USER_NAME\AppData\Local\heroku\client\bin\heroku.cmd from any block list, as well as any other executables from heroku that may be on the list.

Invalid email for Heroku login using Git Bash?

I was able to use heroku login with my windows power shell successfully. However, when running the latest version of Git Bash and running the same heroku login command, after it asks for my email and I enter it I get the following message:
!Login is currently incompatible with git bash/Cygwin/MinGW
Any ideas on how to fix this so I can access Heroku on my Git Bash?
A fix is discussed as a github issue here. You may not have the Path properly set. Some indicate success with logging in via cmd first. If logging via windows cmd doesn't work, exit git bash, login on cmd then restart git bash.
The answer I posted in reply to Push Changes to Git not Functioning worked for me:
Run heroku login using the windows command prompt cmd.exe. This will drop your API key into your _netrc at which point you can open up cygwin or git bash and do whatever you need to
From .gitconfig remove the helper = manager line so that it is no longer registered as a credential helper and stops it from showing up.
(in C:\Users\username\.gitconfig )
Rename _netrc file to .netrc on Windows 7 in the user dir:
cd %home%
REN _netrc .netrc
see:
'git push heroku master' is still asking for authentication
https://github.com/heroku/cli/issues/84#issuecomment-170689175

Setup heroku environment on different machine

I have two laptops, one work laptop and another personal laptop. I have setup the Heroku environment on the work laptop. In git repo I have added github as origin and heroku as separate remote. Whenever I need to deploy anything I just use heroku remote to push my changes.
Now I have already cloned my code from github and also installed heroku-toolbelt on the second laptop. Now I want to push my code and access Postgres database from second laptop. But not sure how to do it. I am able to see the app config parameter by this command.
heroku config --app <MY-APP-NAME>
But when I try to access database I am not able to do so. The pg sub-command doesn't provide --app option to specify the app name.
I tried to look into heroku fork but this command will basically create another app from an existing app. I don't want to do this.
I also looked into herku git:clone but this command will basically clone the repo. I have already cloned my repo from githu.
I am not sure how to have the same heroku enviornment as I have on my work laptop.
EDIT1
I executed the following command to add heroku remote in git config.
heroku git:remote -a <MY-APP-NAME>
So I don't need to specify the --app option to access the config. It automatically picks the right config. But I when I try to access the Postgres database it gives me following error.
>heroku pg:psql
---> Connecting to DATABASE_URL
sh: psql: command not found
This exact same command works on another laptop.
EDIT2
I figured out the problem. Actually heroku is trying to run psql on my local box but psql was not installed on my machine and hence it couldn't successfully connect to remote database. So I executed the following command to install psql and it worked like charm.
brew install postgres
First add the git remote by executing the following line.
heroku git:remote -a <MY-APP-NAME>
Then make sure your system has the postgres client installed. If it is not installed then installed it using the following command.
brew install postgres
The above command is only valid for Mac which has brew installed. You can search internet to find the specific command for your own platform.

Resources