bash “错误的解释器:不允许操作” El Capitan 上的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37740411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
“bad interpreter: Operation not permitted” Error on El Capitan
提问by Santanu Karar
My team is writing a Mac OS application that needs to call a shell script in an external directory.
我的团队正在编写一个需要在外部目录中调用 shell 脚本的 Mac OS 应用程序。
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:
该应用程序在优胜美地 (10.10.3) 上运行良好。但是,如果我在 El Capitan (10.11.2) 上运行它,应用程序会从脚本中收到如下错误:
/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.
应用程序使用文件选择器打开脚本目录。我确认应用程序可以从这个目录读取其他文件。
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.
更改/bin/sh
为/bin/bash
或/bin/sh
在不同路径上的副本使用新的解释器路径会产生相同的错误。
A coworker tested this issue on a El Capitan machine with System Integrity Protection disabled, but he got the same error.
一位同事在禁用系统完整性保护的 El Capitan 机器上测试了这个问题,但他得到了同样的错误。
I am installing the test application from a .pkg file. The entitlements are:
我正在从 .pkg 文件安装测试应用程序。权利是:
<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/>
Adding the com.apple.security.files.user-selected.executable
entitlement did not make a difference
添加com.apple.security.files.user-selected.executable
权利没有任何区别
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.
如果我尝试运行在包构建的中间步骤中生成的 .app,我可以运行脚本而不会出错。
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.
下面的问题描述了一个类似的错误。但是,我检查了应用程序和脚本,发现都没有com.apple.quarantine
设置属性。
Mac OS: /usr/bin/env: bad interpreter: Operation not permitted
Mac 操作系统:/usr/bin/env:错误的解释器:不允许操作
--- UPDATE ----
- - 更新 - -
We added two more in PKG entitlement list:
我们在 PKG 权利列表中又添加了两个:
<key>com.apple.security.scripting-targets</key>
<true/>
<key>com.apple.security.temporary-exception.apple-events</key>
<true/>
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 (.scpt) 文件(存储在应用程序目录中)运行简单的 .sh 文件,我们还确认 .sh 文件和 .scpt 文件也有任何扩展属性,但我们仍然有那个错误.
Following shows ls -@Oel
commands on both AppleScript and shell script file respectively.
下面分别显示ls -@Oel
了 AppleScript 和 shell 脚本文件上的命令。
$ 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
回答by OsamaBinLogin
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:
试试这个:
$ ls -l@ whereverthescriptis
如果它说它有com.apple.quarantine,那就是问题所在。在其上运行其中一个,从最不危险到最危险:
$ 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
回答by islam XDeveloper
i am solve it if you using pods just
如果您只使用豆荚,我会解决它
- pod clean
- pod install
- 豆荚清洁
- 吊舱安装
and project ready to run
和项目准备运行