命令行工具 bash (git)不工作-macOS Sierra 最终版候选

我刚刚从 OS X 10.11“ El Capitan”升级到 10.12: “ Sierra”,当我尝试访问终端中的 git 命令时,我得到以下错误:

错误: 无效的活动开发人员路径

(/Library/Developer/CommandLineTools) ,缺少 xcrun:

/Library/Developer/CommandLineTools/usr/bin/xcrun

请帮助我,如果有人有解决方案。

35402 次浏览

Re-install Xcode developer tools

xcode-select --install

I fixed this issue by downloading and installing the 'Command Line Tools (macOS sierra) for Xcode 8' package from Apple Developer Downloads.

Be sure to select Command Line Tools (macOS 10.12) for Xcode 8 and not the one for 8.1 beta unless you have Xcode 8.1 beta installed.

Had same problem and with putting the git's path into profile directly it will not ask the xcode anymore (if you dont need to use xcode).

  1. download the git, https://git-scm.com/download/mac and install it.
  2. in your profile add to path, i.e. export PATH=$PATH:/usr/bin (mine git is in /usr/bin).
  3. open new terminal.

Alone - xcode-select --install did not work for me.

Had to do all 3 steps:

  1. Download X-code from app store (if not present in Applications folder)
  2. $xcode-select --install
    a. May need to update after install using softwareupdate in command line. $sudo softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-9.1"

  3. $sudo xcodebuild -license

I just recently upgraded to macOS High Sierra Version 10.13.3 and has existing xcode. My git command lines have the same issue. "$xcode-select --install" works perfectly for me.