首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bazel无法运行xcrun,但xcode和xcrun已在本地正确安装。

Bazel无法运行xcrun,但xcode和xcrun已在本地正确安装。
EN

Stack Overflow用户
提问于 2019-10-14 23:06:12
回答 1查看 371关注 0票数 0

我在试着运行bazel建筑。在此过程中,我看到了以下错误消息

调试: /private/var/tmp/_bazel_antkong/cf188c7bd288685357ff03fcbb494066/external/bazel_tools/tools/osx/xcode_configure.bzl:87:9:调用xcodebuild失败,developer dir: /Applications/Xcode.app/Contents/Developer,返回代码256,stderr: java.io.IOException:无法运行程序"xcrun“(在目录"/private/var/tmp/_bazel_antkong/cf188c7bd288685357ff03fcbb494066/external/local_config_xcode"):error=2中,没有这样的文件或目录,stdout:

以下是代码:

代码语言:javascript
复制
 46 def _xcode_version_output(repository_ctx, name, version, aliases, developer_dir):
 47     """Returns a string containing an xcode_version build target."""
 48     build_contents = ""
 49     decorated_aliases = []
 50     error_msg = ""
 51     for alias in aliases:
 52         decorated_aliases.append("'%s'" % alias)
 53     xcodebuild_result = repository_ctx.execute(
 54         ["xcrun", "xcodebuild", "-version", "-sdk"],
 55         30,
 56         {"DEVELOPER_DIR": developer_dir},
 57     )
 58     if (xcodebuild_result.return_code != 0):
 59         error_msg = (
 60             "Invoking xcodebuild failed, developer dir: {devdir} ," +
 61             "return code {code}, stderr: {err}, stdout: {out}"
 62         ).format(
 63             devdir = developer_dir,
 64             code = xcodebuild_result.return_code,
 65             err = xcodebuild_result.stderr,
 66             out = xcodebuild_result.stdout,
 67         )
 68     ios_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "iphoneos")
 69     tvos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "appletvos")
 70     macos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "macosx")
 71     watchos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "watchos")
 72     build_contents += "xcode_version(\n  name = '%s'," % name
 73     build_contents += "\n  version = '%s'," % version
 74     if aliases:
 75         build_contents += "\n  aliases = [%s]," % " ,".join(decorated_aliases)
 76     if ios_sdk_version:
 77         build_contents += "\n  default_ios_sdk_version = '%s'," % ios_sdk_version
 78     if tvos_sdk_version:
 79         build_contents += "\n  default_tvos_sdk_version = '%s'," % tvos_sdk_version
 80     if macos_sdk_version:
 81         build_contents += "\n  default_macos_sdk_version = '%s'," % macos_sdk_version
 82     if watchos_sdk_version:
 83         build_contents += "\n  default_watchos_sdk_version = '%s'," % watchos_sdk_version
 84     build_contents += "\n)\n"
 85     if error_msg:
 86         build_contents += "\n# Error: " + error_msg.replace("\n", " ") + "\n"
 87         print(error_msg)
 88     return build_contents

但是,如果我直接运行xcrun,我可以成功地运行它。以下是部分输出:

代码语言:javascript
复制
WatchOS6.0.sdk - watchOS 6.0 (watchos6.0)
SDKVersion: 6.0
Path: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS6.0.sdk
PlatformVersion: 6.0
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform
BuildID: 7CDF745C-BD9D-11E9-9623-6BA52C36DD1A
ProductBuildVersion: 17R566
ProductCopyright: 1983-2019 Apple Inc.
ProductName: Watch OS
ProductVersion: 6.0

WatchSimulator6.0.sdk - Simulator - watchOS 6.0 (watchsimulator6.0)
SDKVersion: 6.0
Path: /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator6.0.sdk
PlatformVersion: 6.0
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform
BuildID: 7CDF745C-BD9D-11E9-9623-6BA52C36DD1A
ProductBuildVersion: 17R566
ProductCopyright: 1983-2019 Apple Inc.
ProductName: Watch OS
ProductVersion: 6.0

Xcode 11.1

那我该怎么解决这个问题呢?

EN

回答 1

Stack Overflow用户

发布于 2019-10-16 09:37:40

看起来xcrun就在路径上,但在运行操作时却不是这样。用--verbose_failures检查这一点: Bazel将打印失败的命令及其envvars;查看xcrun是否在它的路径上。如果不是,那么也许您是用环境构建的。另见环境

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58385105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档