A possible solution to 'bad interpreter: operation not permitted' error on Mac OS X Lion


This post was published in 2012 and is kept here for reference. It may contain information that's outdated or inaccurate.

Out of the blue I started having an issue in my Terminal.app on Lion where downloaded scripts/applications wouldn’t run. I first noticed this when trying to setup the Android SDK.

The problem looks like this:

$ ./android: /bin/sh: bad interpreter: Operation not permitted

After a bit of Google-fu, and a bunch of Apple Support Community threads that ended in people arguing about whether or not TextEdit caused this issue, I found a cause and a solution.

It turns out that for some reason, on Mac OS X Lion 10.7.3 apple is storing a com.apple.quarantine metadata file, which prevents executable files from being executed. Why is it doing this? Probably because the executable file was downloaded from the internet? who knows?

Anyway, there is a solution:

$ xattr -rd com.apple.quarantine [directory containing the executables]

So, for me with the Android SDK, I ran the following:

$ xattr -rd com.apple.quarantine /android-sdk/

This command deletes the com.apple.quarantine metadata files, allowing you to execute the executables.

This post is also available in plain text

[Archived comments]

Jake commented

thanks, it worked

Andrew commented

Great Result…… Was having a problem with a sparseImage and executed the xattr command on the image file and the problem just went away! thanks!

nickjouannem commented

Thanks for posting about this.

Jaime commented

Thanks a lot, it worked!!!

John commented

dont have appropriate permissions… im on administrator account

[Comments]

Want to comment? You can do so via Github.
Comments via Github are currently closed.

[Webmentions]

Want to reply? I've hooked up Webmentions, so give it a go!