mac 安裝homobrew 報錯解決

按照官網(https://brew.sh/index_zh-cn.html)給的命令:html

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"git

執行後 報錯:github

   xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'
   Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineToolsxcode

從報錯來看,是說 /Library/Developer/CommandLineTools 不是 xcode-select 的有效路徑ruby

那麼要作的就有兩件事:app

      1.找到 xcode-select的有效路徑curl

  2.使用有效路徑替換 https://raw.githubusercontent.com/Homebrew/install/master/install 文件中的 /Library/Developer/CommandLineToolsui

 

1.查找 xcode-select的有效路徑this

使用命令:xcode-select 查看其用法url

userNameMacBook-Pro:test userName$ xcode-select

xcode-select: error: no command option given

Usage: xcode-select [options]

 

Print or change the path to the active developer directory. This directory

controls which tools are used for the Xcode command line tools (for example, 

xcodebuild) as well as the BSD development commands (such as cc and make).

 

Options:

  -h, --help                  print this help message and exit

  -p, --print-path            print the path of the active developer directory

  -s <path>, --switch <path>  set the path for the active developer directory

  --install                   open a dialog for installation of the command line developer tools

  -v, --version               print the xcode-select version

  -r, --reset                 reset to the default command line tools path

執行:xcode-select -p找到真正的路徑,輸出

  /Applications/Xcode.app/Contents/Developer 即 xcode-select的有效路徑

 

2.使用有效路徑:/Applications/Xcode.app/Contents/Developer

  替換 https://raw.githubusercontent.com/Homebrew/install/master/install 文件中的 /Library/Developer/CommandLineTools

  將https://raw.githubusercontent.com/Homebrew/install/master/install 內容複製下來,將第306和315行兩處的/Library/Developer/CommandLineTools

  改成/Applications/Xcode.app/Contents/Developer 並保存名爲 install的文件

3.進入保存的install文件目錄下,執行 

ruby -e "$(cat install)"便可

相關文章
相關標籤/搜索