Heroku: "bash: ./start.sh: Permission denied"
Asked Answered
S

1

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

Stoeber answered 14/2, 2015 at 4:27 Comment(2)
What's the file permissions?Myxomatosis
On my local computer? Or on Heroku?Stoeber
I
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)

Incontinent answered 14/2, 2015 at 4:38 Comment(6)
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?Stoeber
@Nifty255: Yes, the file has to have executable permissions on the machine where it is run.Incontinent
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.Stoeber
@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, serverfault.com/questions/tagged/herokuIncontinent
I can't find your question "how to change permissions on Heroku" on servefault... What exactly was your workaround?Balmy
@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. (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 :-)Incontinent

© 2022 - 2024 — McMap. All rights reserved.