158

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?

andy mccullough
  • 9,070
  • 6
  • 32
  • 55
  • It doesn't seem like it's possible: http://stackoverflow.com/questions/12763440/how-to-access-files-on-heroku – mightimaus May 01 '17 at 16:50

5 Answers5

312

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
Shady Mohamed Sherif
  • 15,003
  • 4
  • 45
  • 54
Juliano Araújo
  • 3,548
  • 1
  • 11
  • 16
  • 1
    not working on mac. we should pass the app name on the same line heroku run bash --app – HMagdy Feb 08 '19 at 14:26
  • 4
    heroku run bash --app your-app-name – Neil Jul 21 '19 at 08:57
  • 1
    @HMagdy Actually this is correct only if you are in your current working directory. It is important to note that this working directory should be linked with Heroku. Meaning that you must have pushed its contents to heroku master. You only need the -app-name flag if you are not in the working directory. – Olu Adeyemo Oct 24 '19 at 04:16
  • C:\Users\user>heroku run bush --app fast-island-39166 Running bush on ⬢ fast-island-39166... up, run.2379 (Free) bash: bush: command not found - here is what going on on windows!!! –  Oct 29 '19 at 07:02
  • after start a session with heroku login and then run the command heroku run bash --app your-app-name, work for me as said in the answer. – Ornelio Chauque Jun 30 '20 at 13:43
  • 1
    Your application may not reside in an "app" folder. Run "dir" (or "ls") to see folder structure. In the case of worker bots, there may simply be some files there. – Coreus Nov 11 '20 at 12:27
  • Its says : *Error: Cannot find module '/app/bash'* – Ibad Shaikh Sep 10 '21 at 16:58
35

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.

DJR-MiqroMeq
  • 351
  • 3
  • 3
9

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

sam
  • 1,005
  • 1
  • 11
  • 24
3

`

  • app settings option gives our files url

` settings

Then use git clone

  • git clone https://git.heroku.com/your_app_name.git
Alauddin Sabari
  • 181
  • 1
  • 5
3

You can do this with,

heroku run bash -a APPNAME

If the above command fails,

heroku run sh -a APPNAME
Nijoo
  • 227
  • 3
  • 5