Running C Program on Heroku: No such file

Question:

I am trying to open a C program in a python script running on a Heroku dyno. The Python script works fine locally, but on the dyno it says that the executable cannot be found. The line to run the program in Python is:

proc = subprocess.Popen(["./backend/test-print"], stdout=subprocess.PIPE, stderr=subprocess.PIPE),

where backend is the folder that contains the program test-print and the Python script. I run the Python scripy from the folder root so it finds the script just fine. The Heroku logs say:

FileNotFoundError: [Errno 2] No such file or directory: './backend/test-print'.

If I run bash on the dyno and try to run the program manually, it gives the same error:

Running bash on ⬢ ******** ... up, run.8123 (Eco)
~ $ cd backend
~/backend $ ls
server.py  test-print
~/backend $ ./test-print
bash: ./test-print: No such file or directory

Any ideas? Thanks in advance. I built the program test-print on my local machine (not the one I am running the program on).

I tried putting the program in the root /app folder to see if it would be found then, but that did not work.

EDIT: I should also add that when I cat test-print, it finds the file fine and prints its contents.

EDIT: type test-print outputs

~/backend $ type test-print 
bash: type: test-print: not found

EDIT:

~/backend $ ls -laQ
total 28
drwx------ 2 u5587 dyno  4096 Feb 20 16:16 "."
drwx------ 5 u5587 dyno  4096 Feb 20 17:08 ".."
-rw------- 1 u5587 dyno   520 Feb 20 16:16 "server.py"
-rwx------ 1 u5587 dyno 16176 Feb 20 16:16 "test-print"
~/backend $ ls -laq
total 28
drwx------ 2 u5587 dyno  4096 Feb 20 16:16 .
drwx------ 5 u5587 dyno  4096 Feb 20 17:08 ..
-rw------- 1 u5587 dyno   520 Feb 20 16:16 server.py
-rwx------ 1 u5587 dyno 16176 Feb 20 16:16 test-print

~/backend $ id
uid=13747(u13747) gid=13747(dyno) groups=13747(dyno)
Asked By: Cole White

||

Answers:

There are different user names u5587 vs u13747 in the output of ls and id.

~/backend $ ls -laq
total 28
drwx------ 2 u5587 dyno  4096 Feb 20 16:16 .
drwx------ 5 u5587 dyno  4096 Feb 20 17:08 ..
-rw------- 1 u5587 dyno   520 Feb 20 16:16 server.py
-rwx------ 1 u5587 dyno 16176 Feb 20 16:16 test-print

~/backend $ id
uid=13747(u13747) gid=13747(dyno) groups=13747(dyno)

User u13747 does not have the permission to list the contents of the current directory or to access anything in this directory because it is owned by a different user and has no permissions for the group dyno or others.

(This does not explain why cat test-print would work.)

Answered By: Bodo
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.