“糟糕的翻译:不允许操作”El Capitan

时间:2016-06-10 05:18:52

标签: bash file-permissions osx-elcapitan mac-app-store pkg-file

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

该应用程序在优胜美地(10.10.3)上运行良好。但是,如果我在El Capitan(10.11.2)上运行它,应用程序会从脚本中获得这样的错误:

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

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

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

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

应用程序使用filechooser打开脚本目录。我确认该应用程序可以从该目录中读取其他文件。

在不同路径上将/bin/sh更改为/bin/bash/bin/sh的副本会在新解释器路径中出现相同的错误。

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

我正在从.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/>

添加com.apple.security.files.user-selected.executable权利没有什么区别

如果我尝试运行在包构建的中间步骤中生成的.app,我可以运行脚本而没有错误。

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

Mac OS: /usr/bin/env: bad interpreter: Operation not permitted

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

---更新----

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

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

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

以下分别在AppleScript和shell脚本文件中显示ls -@Oel命令。

$ 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

3 个答案:

答案 0 :(得分:1)

我希望这会对某人有所帮助,因为我的解决方案是上述问题的一个稍微独特的解决方案:我让其他人为我做代码,所以当我得到代码时,它不会以“不允许操作”状态运行在 Android 和 iOS 上。

事实证明,我必须转到包含该项目的文件夹,并取得该文件夹的所有权。您可以在 Mac 上执行此操作,方法是转到包含 Flutter 项目的文件夹,然后从上下文菜单中单击“获取信息”。然后将您的访问权限更改为“只读”,然后回到底部最后一个窗格中的“写入和读取”。

按照上述建议之一,转到终端,从文件夹中删除 Apple 隔离属性,然后使用“cd”命令导航到包含 Flutter 项目的文件夹,并键入以下命令:

xattr -dr com.apple.quarantine [your flutter project directory name]

就是这样!现在,Android Studio 或您选择的 IDE 将能够从该文件夹运行 iOS 和 Android 版本。

答案 1 :(得分:0)

尝试:     $ 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

答案 2 :(得分:-1)

如果您仅使用Pod,我会解决

  1. 干净的豆荚
  2. pod安装

并准备好运行项目

相关问题