GitLab CI python subprocess.Popen permission denied

Question:

I’m running a GitLab-CI job which runs a python script which starts a subprocess.Popen(...).

def main():
  proc = subprocess.Popen("./../binary_file --args value", stdout=subprocess.PIPE)

The problem is that I’m getting

PermissionError: [Errno 13] Permission denied: ‘./../binary_file’

Ok. Maybe I forgot to set appropriate permissions?

$ chmod +x ./binary_file
$ ls -l ./binary_file
-rwxr-xr-x 1 root root 30335023 Apr  1 14:16 ./binary_file
$ whoami
root

Well I’m not.

So what could be the reason of such behavior?

The script part of a gitlab-ci job

script:
    - chmod +x ./binary_file
    - ls -l ./binary_file
    - whoami
    - pipenv run python ./scripts/run_tests.py
Asked By: Bob

||

Answers:

based on the code that you provided, I see the different paths to the file in the script and the python file. Make sure that the path is correct. Try using os.getcwd().

Answered By: RAI
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.