查找Xcode的命令行工具的路径位置



我不想安装整个Xcode,所以我只是下载了Xcode的命令行工具。我正在尝试通过rvm安装ruby 1.9.3。然而,rvm抱怨没有选择xcode:

xcode select:错误:未选择xcode。使用xcode select-switch,或参阅xcode select手册页(man-xcode select)以获取更多信息。

我阅读了xcode-select手册页,知道如何设置Xcode命令行工具的路径,但我不知道它们安装在哪里。我该如何找到答案?

我正在使用OS X Mountain Lion。

/usr/bin中的条目只是您使用xcode-select:选择的任何内容的前面

$> /usr/bin/clang --version
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

独立的命令行工具安装在/Library/Developer/CommandLineTools:中

$> sudo xcode-select -s /Library/Developer/CommandLineTools
$> /usr/bin/clang --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin 

这对我很有效:sudo xcode-select --reset

短版本:我的问题的答案是安装完整的Xcode,而不仅仅是命令行工具。

长版本:

基于此,我发现工具的位置是/usr/bin。所以我运行了sudo xcode-select -switch /usr/bin。然而,在那之后,我得到了这个错误:

错误:无法执行真正的xcrun。(没有这样的文件或目录)

因此,基于此,我安装了完整的Xcode应用程序,运行了sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer,这解决了我的问题。

如果你的用户文件夹在外部驱动器上,这对我来说很有效:

sudo xcode-select --switch /Library/Developer/CommandLineTools

对于独立安装。

这不是来自RVM的警告,很可能是由Homebrew显示的,我很少收到抱怨,但它总是无害的,ruby的安装也顺利完成。

如果出现错误,请显示所有错误,而不仅仅是一个错误。

最新更新