Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CircleCI permission denied running bash script

Tags:

bash

circleci

I have a circle.yml file like so:

dependencies:   override:     - meteor || curl https://install.meteor.com | /bin/sh  deployment:   production:     branch: "master"     commands:       - ./deploy.sh 

When I push to Github, I get the error:

/home/ubuntu/myproject/deploy.sh returned exit code 126  bash: line 1: /home/ubuntu/myproject/deploy.sh: Permission denied Action failed: /home/ubuntu/myproject/deploy.sh 

When I run the commands that live inside deploy.sh outside of the file (under commands) everything runs fine.

Everything in the circle.yml file seems to be in line with the examples in the CircleCI docs.. What am I doing wrong?

like image 434
samcorcos Avatar asked Nov 26 '15 16:11

samcorcos


People also ask

How do I fix bash permission denied?

Solution to fix the bash: ./program_name: permission denied error. chmod u+x program_name– In this line, the chmod command will change the access mode to execute, denoted by x. only the file's owner will have the permission to execute the file.

How do I run shell script Permission denied?

To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode) command for this purpose.

How do I fix bash Permission denied in Ubuntu?

The Bash permission denied error indicates you are trying to execute a file which you do not have permission to run. To fix this issue, use the chmod u+x command to give yourself permissions. If you cannot use this command, you may need to contact your system administrator to get access to a file.

How do I fix Permission denied in Linux?

For solving this error, you need to add the correct permissions to the file to execute. However, you need to be a “root” user or have sudo access for changing the permission. For changing the permission, Linux offers a chmod command.


2 Answers

Several possible problems:

  1. deploy.sh might not be marked as executable (chmod +x deploy.sh would fix this)
  2. The first line of deploy.sh might not be a runnable shell...

If the first doesn't work, can we please see the contents of deploy.sh?

like image 68
Tom Parker-Shemilt Avatar answered Oct 06 '22 12:10

Tom Parker-Shemilt


I was having the same issue. I added sh to the front of my commands section to get it to work.

deployment:   production:     branch: "master"     commands:       - sh ./deploy.sh 

Hopefully that fix saves everyone sometime going forward.

like image 31
Jesse Sanders Avatar answered Oct 06 '22 14:10

Jesse Sanders