2 posts categorized "FutureMe"


Bad Interpreter Errors Executing Scripts in OS X

Apparently, this is a well-documented issue people experience in OS X, (I, personally, do not recall experiencing it with third-party shell scripts prior to my 10.7.4 install but that could just be coincidental since I do not build from source all that often). Download a source archive from the Internet somewhere, then execute 'configure' to start building it, and you get the following error:

-bash: ./configure: /bin/sh: bad interpreter: Operation not permitted

For those familiar with the warning regarding opening files downloaded from the Internet when launching them with a mouse click, the error message above is that equivalent when executing something from the command line. The OS X extended attribute com.apple.quarantine is applied to executable files, which needs to be removed in order to run them. To fix, execute the following command in the terminal window (only after being certain that the files you want to strip the com.apple.quarantine extended attribute from are from trusted sources):

xattr -rd com.apple.quarantine /directory/path/to/files

If you run ls -l in those source directories prior to stripping out the extended attribute, you'll see permissions similar to the following set on executables and subdirectories within that directory:

-rwxr-xr-x@   1 uid  gid  315293 Nov  5  2011 configure*

After running the xattr command, permissions look like this (note the missing @ symbol):

-rwxr-xr-x    1 uid  gid  315293 Nov  5  2011 configure*


Build Note for Valgrind 3.7.0 on OS X 10.7.4

While getting started with Zed Shaw's Learn C The Hard Way book, I experienced the following error running 'configure' when building Valgrind from source:

-bash: ./configure: /bin/sh: bad interpreter: Operation not permitted

In order to get the Valgrind configure script to run under OS X (Lion) 10.7.4, I had to prepend "bash" in front of "configure":

bash ./configure

Update: And, this might not be the right way to do it since running make after a successful configure creates an install-sh script that needs the shebang #!/bin/sh replaced with #!/bin/bash before a sudo make install will work...Valgrind is installed though!

Update #2: Apparently, files downloaded from the Internet that have the executable bits set on them are flagged as of OS X 10.7.3 (possibly earlier) that prevent them from running unless a prompt is accepted first. Shell scripts will have those flags set as well but instead of being able to accept a prompt, you get the bad interpreter: Operation not permitted message. Running the following command in the terminal will remove the com.apple.quarantine extended attribute from the files:

xattr -rd com.apple.quarantine /directory/containing/executables/you/want/to/run

This is a note to my future self in case I run into it again building future versions of Valgrind.