Mac 安装 brew & brew cask 遇到的问题及解决办法
安装 brew
在 Terminal 执行 提供的命令即可
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Error
Warning: /usr/local/bin is not in your PATH. ==> Installation successful!
显示这个说明安装失败了,执行 brew 命令的话会显示
-bash: brew: command not found
解决办法
将 /usr/local/bin 添加到环境变量里:
//先进入到用户级环境变量配置文件中 $ vim ~/.bash_profile //在文件最后添上 export PATH=/usr/local/bin:$PATH
配置完记得source一下,然后重新安装即可。
Mac系统的环境变量,加载顺序为: /etc/profile /etc/paths ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc /etc/profile和/etc/paths是系统级别的,系统启动就会加载。 后面几个是当前用户级的环境变量,按照从前往后的顺序读取,如果~/.bash_profile文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile文件不存在,才会以此类推读取后面的文件。~/.bashrc没有上述规则,它是bash shell打开的时候载入的。
安装 brew cask
在 Terminal 执行以下命令:
$brew tap phinze/homebrew-cask $brew install brew-cask
Error
在执行第二条命令时可能会遇到以下错误信息
Error: No available formula with the name "brew-cask" ==> Searching for a previously deleted formula (in the last month)... Warning: homebrew/core is shallow clone. To get complete history run: git -C "$(brew --repo homebrew/core)" fetch --unshallow Error: No previously deleted formula found. ==> Searching for similarly named formulae... This similarly named formula was found: brew-cask-completion To install it, run: brew install brew-cask-completion ==> Searching taps... ==> Searching taps on GitHub... Error: No formulae found in taps.
解决办法
使用错误信息里推荐的安装,执行以下命令:
$brew install brew-cask-completion
安装成功后使用 brew cask 试一下:
$brew cask install qlmarkdown
Mac上,选择一个文件,按空格就可以快速预览文件内容,通过homebrew cask安装一些小扩展插件可以让我们预览更多的文件类型,qlmarkdown 可以预览 Markdown 文件。