17

I have an app with a Procfile set to run a shell script, but Heroku will not run the script, stating "Permission denied".

Procfile:
web: ./start.sh
start.sh:
#!/usr/bin/env bash
clear;
until node app.js; do
    echo "Server crashed with exit code $?.  Respawning.." >&2
    sleep 1
done
Heroku log:

Starting process with command './start.sh'
bash: ./start.sh: Permission denied
State changed from starting to crashed
Process exited with status 126

Let Me Tink About It
  • 15,156
  • 21
  • 98
  • 207
Nifty255
  • 397
  • 2
  • 3
  • 14

1 Answers1

26

For that to work, start.sh must be executable:

chmod a+x start.sh

If you cannot arrange for that to happen on the machine where the file runs, you can invoke it directly with bash; instead of ./start.sh, use bash ./start.sh (or even just bash start.sh)

rici
  • 234,347
  • 28
  • 237
  • 341
  • I ran this command, and all it did was add a line between sleep 1 and done in the file. I committed and pushed regardless, and no success. Do I need to run this command on Heroku somehow? – Nifty255 Feb 14 '15 at 04:44
  • @Nifty255: Yes, the file has to have executable permissions on the machine where it is run. – rici Feb 14 '15 at 04:45
  • 1
    Then how do I change the permissions of the file on Heroku? I've done it on my computer, but it seems not to have done much good. – Nifty255 Feb 14 '15 at 04:47
  • @Nifty255: I don't know, and it's not really a programming problem. I provided an alternative in an edit; you might want to ask the "how to change permissions on Heroku" question on, for example, http://serverfault.com/questions/tagged/heroku – rici Feb 14 '15 at 04:51
  • I can't find your question "how to change permissions on Heroku" on servefault... What exactly was your workaround? – Aamir Mulla Mar 08 '21 at 03:28
  • 1
    @AamirMulla: I didn't answer a question on "how to change permissions on Heroku". I suggested that OP ask that particular question on that particular community, where it might be possible that someone knowledgeable would answer (that is, not me). What I did do was edit my answer; you can see the modification by clicking on the link which says [edited Feb 14 '15 at 4:46](https://stackoverflow.com/posts/28512490/revisions). (I added the final paragraph to my answer: "Use `bash start.sh`"). If you want a better answer, I suggest you ask the question on serverfault.com :-) – rici Mar 08 '21 at 03:59