由于想在macOS上安装"wget"命令,但需要先安装brew工具,安装brew工具需要安装xcode,但macOS 10.15.2 默认没有安装xcode,安装了xcode【Version 11.4.1 (11E503a)】之后,通过brew官网的教程给的指令来安装brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
执行后报错:
xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
从报错来看,/Library/Developer/CommandLineTools的确不存在,通过:
xcode-select -p
以找到正确的路径,于是稍微修改一下官方给的指令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | sed 's#/Library/Developer/CommandLineTools#$(xcode-select -p)#')"
于可以看到正确的结果:
Already up-to-date.==> Installation successful!==> Homebrew has enabled anonymous aggregate formulae and cask analytics.Read the analytics documentation (and how to opt-out) here:https://docs.brew.sh/AnalyticsNo analytics data has been sent yet (or will be during this `install` run).==> Homebrew is run entirely by unpaid volunteers. Please consider donating:https://github.com/Homebrew/brew#donations==> Next steps:- Run `brew help` to get started- Further documentation:https://docs.brew.sh
接着按照官方教程安心安装wget命令啦:
$ brew install wget
总的来说来说,mac的包管理器还是比较弱的,不像yum或dnf能够让你飞翔~ ,brew也只是从第三方角度去解决部分问题。