I'm getting «exec format error» when I try to run an executable

Solution 1:

Run

uname -m

and check if the programs you're trying to execute have the appropriate architecture. ie., 32 vs 64 bit.

Solution 2:

Note that this error can also occur if, from within zsh, you attempt to directly execute an executable that has zero bytes (such as might happen when you accidentally truncate an executable shell script or never initialize it; by contrast, if you pass such a script as an argument to zsh, the error does not occur).

Observed on zsh 5.0.2.

Note that bash, ksh, dash do not exhibit this problem - they simply silently ignore such invocations.