Bug in Actions: the same file is executable on MacOS and Linux but is not on Windows

I ran into a super puzzling behaviour. I got a matrix build, that at some point verifies if some file exists and is executable, and in case executes it.
The file was not being executed on windows, yet it was on Linux and MacOS.
I added some debug lines and found the following:

ls -ahl on MacOS (see the “Prepare Environment” step):

total 32
drwxr-xr-x  6 runner  staff   192B Nov 20 16:22 .
drwxr-xr-x  5 runner  staff   160B Nov 20 16:22 ..
-rwxr-xr-x  1 runner  staff   104B Nov 20 16:22 build
-rwxr-xr-x  1 runner  staff    83B Nov 20 16:22 check
-rwxr-xr-x  1 runner  staff   388B Nov 20 16:22 check_environment
-rwxr-xr-x  1 runner  staff   905B Nov 20 16:22 deploy

ls -ahl on Windows (see the “Prepare Environment” step):

total 7.0K
drwxr-xr-x 1 runneradmin 197121   0 Nov 20 16:22 .
drwxr-xr-x 1 runneradmin 197121   0 Nov 20 16:22 ..
-rwxr-xr-x 1 runneradmin 197121 108 Nov 20 16:22 build
-rwxr-xr-x 1 runneradmin 197121  87 Nov 20 16:22 check
-rw-r--r-- 1 runneradmin 197121 397 Nov 20 16:22 check_environment
-rwxr-xr-x 1 runneradmin 197121 931 Nov 20 16:22 deploy

I can work this around but I really cannot figure out why is this happening. I could understand if Windows did not understand UNIX permissions and thus rejected all x permissions, but it does work for other scripts!

I figured it out just after posting it (talking with a text area helps, apparently). I had forgotten a ! in the shebang line of the script.

Apparently, under windows whether something is executable or not is determined by the existence of a correct shebang line.

So if you need to mark something as executable on GitHub Actions do not forget to #! your script correctly :smile:

1 Like