El Capitan上的“口译不好:不允许操作"错误 [英] “bad interpreter: Operation not permitted” Error on El Capitan

查看:72
本文介绍了El Capitan上的“口译不好:不允许操作"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在编写一个Mac OS应用程序,该应用程序需要在外部目录中调用Shell脚本.

My team is writing a Mac OS application that needs to call a shell script in an external directory.

该应用程序在优胜美地(10.10.3)上可以正常工作.但是,如果我在El Capitan(10.11.2)上运行它,则该应用程序会从脚本中获得如下错误:

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:

/bin/bash: <path-to-script>: /bin/sh: bad interpreter: Operation not permitted

我可以在这样的简单脚本上触发此错误:

I can trigger this error on a simple script like this:

#!/bin/sh
echo "Hello World!"

如果从终端手动运行脚本,我不会收到错误消息.

I do not get an error if I run the scripts manually from the Terminal.

应用程序使用文件选择器打开脚本目录.我确认该应用程序可以从该目录读取其他文件.

The application opens the script directory using a filechooser. I confirmed that the application can read other files from this directory.

/bin/sh 更改为/bin/bash 或在不同路径上复制/bin/sh 会产生相同的错误使用新的解释器路径.

Changing /bin/sh to /bin/bash or a copy of /bin/sh on a different path gives the same error with the new interpreter path.

一位同事在禁用了系统完整性保护的El Capitan机器上测试了此问题,但他遇到了同样的错误.

A coworker tested this issue on a El Capitan machine with System Integrity Protection disabled, but he got the same error.

我正在从.pkg文件安装测试应用程序.权利是:

I am installing the test application from a .pkg file. The entitlements are:

<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.files.bookmarks.app-scope</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>

添加 com.apple.security.files.user-selected.executable 权利没有任何作用

如果我尝试运行在软件包构建的中间步骤中生成的.app,我将能够正确运行脚本.

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.

以下问题描述了类似的错误.但是,我同时检查了应用程序和脚本,发现没有人设置 com.apple.quarantine 属性.

The question below describes a similar error. However, I checked both the application and the script, and I found that neither one had the com.apple.quarantine attribute set.

Mac OS:/usr/bin/env:错误的解释器:不允许操作

https://apple.stackexchange.com/questions/49589/bash-applications-mvim-bin-sh-bad-interpreter-operation-not-permitted

-更新

我们在PKG权利列表中又添加了两个:

We added two more in PKG entitlement list:

<key>com.apple.security.scripting-targets</key>
<true/>
<key>com.apple.security.temporary-exception.apple-events</key>
<true/>

我们试图通过AppleScript(.scpt)文件(存储在应用程序目录中)运行简单的.sh文件,我们还确认了.sh文件或.scpt文件也都具有任何扩展属性,但是我们仍然有那个错误.

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.

下面分别在AppleScript和Shell脚本文件上显示 ls-@ Oel 命令.

Following shows ls -@Oel commands on both AppleScript and shell script file respectively.

$ 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

推荐答案

请尝试以下操作: $ ls -l @ wherethethescriptis 如果它说有 com.apple.quarantine ,那就是问题所在.从危险程度最低到危险程度最高的情况运行其中之一:

try this: $ ls -l@ whereverthescriptis If it says it's got com.apple.quarantine, that's the problem. Run one of these on it, from least dangerous to most:

$ xattr -d com.apple.quarantine whereverthescriptis   # delete that attr
$ xattr -c whereverthescriptis    # delete ALL the attrs on file
$ xattr -c *         # on every file in this dir
$ xattr -cr .        # and all subdirectories

这篇关于El Capitan上的“口译不好:不允许操作"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆