title: “bad interpreter: Operation not permitted” Error on El Capitan
body: <p>My team is writing a Mac OS application that needs to call a shell script in an external directory.</p>
  
  <p>The application works fine on Yosemite (10.10.3). However, if I run it on El Capitan (10.11.2), the application gets errors like this from the script:</p>
  
  <pre><code>/bin/bash: &lt;path-to-script&gt;: /bin/sh: bad interpreter: Operation not permitted
  </code></pre>
  
  <p>I can trigger this error on a simple script like this:</p>
  
  <pre><code>#!/bin/sh
  echo "Hello World!"
  </code></pre>
  
  <p>I do not get an error if I run the scripts manually from the Terminal.</p>
  
  <p>The application opens the script directory using a filechooser. I confirmed that the application can read other files from this directory.</p>
  
  <p>Changing <code>/bin/sh</code> to <code>/bin/bash</code> or a copy of <code>/bin/sh</code> on a different path gives the same error with the new interpreter path.</p>
  
  <p>A coworker tested this issue on a El Capitan machine with System Integrity Protection disabled, but he got the same error.</p>
  
  <p>I am installing the test application from a .pkg file. The entitlements are:</p>
  
  <pre><code>&lt;key&gt;com.apple.security.app-sandbox&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;com.apple.security.network.client&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;com.apple.security.files.bookmarks.app-scope&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;com.apple.security.files.user-selected.read-write&lt;/key&gt;
  &lt;true/&gt;
  </code></pre>
  
  <p>Adding the <code>com.apple.security.files.user-selected.executable</code> entitlement did not make a difference</p>
  
  <p>If I try to run the .app that is generated in an intermediate step in the package build, I am able to run the script with no errors.</p>
  
  <p>The question below describes a similar error. However, I checked both the application and the script, and I found that neither one had the <code>com.apple.quarantine</code> attribute set.</p>
  
  <p><a href="https://stackoverflow.com/questions/9952612/mac-os-usr-bin-env-bad-interpreter-operation-not-permitted">Mac OS: /usr/bin/env: bad interpreter: Operation not permitted</a></p>
  
  <p><a href="https://apple.stackexchange.com/questions/49589/bash-applications-mvim-bin-sh-bad-interpreter-operation-not-permitted">https://apple.stackexchange.com/questions/49589/bash-applications-mvim-bin-sh-bad-interpreter-operation-not-permitted</a></p>
  
  <p>--- UPDATE ----</p>
  
  <p>We added two more in PKG entitlement list:</p>
  
  <pre><code>&lt;key&gt;com.apple.security.scripting-targets&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;com.apple.security.temporary-exception.apple-events&lt;/key&gt;
  &lt;true/&gt;
  </code></pre>
  
  <p>We tried to run the simple .sh file by an AppleScript (.scpt) file (stored in application directory), we also confirmed that the .sh file nor the .scpt file has any extended attribute as well, but we still have that error.</p>
  
  <p>Following shows <code>ls -@Oel</code> commands on both AppleScript and shell script file respectively.</p>
  
  <pre><code>$ ls -@Oel TestMXMLCall.scpt 
  -rwxrwxrwx  1 root  wheel  - 2302 Jun 15 03:12 TestMXMLCall.scpt
  $ ls -@Oel /usr/local/bin/mxmlc
  -rwxr-xr-x  1 santanukarar  staff  - 2190 Jun 15 01:17 /usr/local/bin/mxmlc
  </code></pre>