Wednesday, February 11, 2009

HOWTO not get "/usr/bin/env: bad interpreter"

If you get this:

bash: ./my-script.py: /usr/bin/env: bad interpreter: Permission denied

The partition your script lives on may be mounted with the "user" option set. "user" implies "noexec" (see the manpage for "mount"), which is going to keep you from running executables. And while running a binary executable from this kind of partition fails more clearly, trying to run a script with a shebang gives you this more confusing error message.

To fix! Add "exec" after your "user" flag in /etc/fstab. (again, see "man mount").

5 comments:

Anonymous said...

very interesting solution that help me a lot. Never more i'll get this error again!

Unknown said...

Great! Thanks for the comment :)

I figured that if I ran into the problem, surely somebody else would have it...

Anonymous said...

Thanks, it was exactly what I needed

erikig said...

Just in case anyone is wondering about the details the command to remount with exec permissions is:

mount -o remount,exec /dev/sdaX

where /dev/sdaX is mounted with noexec

Harold Fisher said...

Goodd reading this post