当前位置: 首页 > 工具软件 > Homebrew Cask > 使用案例 >

MacBook(macOS) 如何安装 Homebrew Cask(作废)

洪浩波
2023-12-01

重要通知(不要再去安装 Homebrew Cask 了)

To start using Homebrew Cask, you just need Homebrew installed.
Homebrew Cask is implemented as part of Homebrew. All Homebrew Cask commands begin with brew, which works for both Casks and Formulae. The most frequently-used commands are:
1.install — installs the given Cask
2.uninstall — uninstalls the given Cask
3.reinstall — reinstalls the given Cask
4.list --casks — lists installed Casks

Homebrew Cask 不需要再单独安装了,新版的 Homebrew 已经整合了 Cask 全部的功能,不仅如此,在安装 Cask 时,也不再需要使用类似 brew cask 这样命令,一律使用命令 brew 即可,理解下面这句话:

All Homebrew Cask commands begin with brew, which works for both Casks and Formulae.

Homebrew Cask 的项目主页地址:https://github.com/Homebrew/homebrew-cask

How to Use Homebrew Cask:https://github.com/Homebrew/homebrew-cask/blob/master/USAGE.md#how-to-use-homebrew-cask

Homebrew Cask 简介

“To install, drag this icon…” no more!
Homebrew Cask extends Homebrew and brings its elegance, simplicity, and speed to the installation and management of GUI macOS applications such as Atom and Google Chrome.
We do this by providing a friendly CLI workflow for the administration of macOS applications distributed as binaries.

Homebrew Cask 相当于 Homebrew 的扩展,区别在于,brew 命令首先获取程序源码然后编译安装(包括依赖库),并自动做好必要的配置(如环境变量等);而 brew cask 命令是下载已经编译好的软件包并放在统一的目录中。

brew cask 命令用来安装 Mac 上的 Gui 程序应用包(.dmg.pkg),比如 qq、chrome 等。它先下载解压软件包到统一的目录中(/opt/Homebrew Cask/Caskroom),省掉了自己去下载、解压、拖拽(安装)等步骤。然后再软链到 ~/Applications/ 目录下, 非常方便,而且还包含很多在 AppStore 里没有的常用软件。

相关文件和目录

Homebrew Cask 是将应用程序放置在 /opt/Homebrew Cask/Caskroom/ 下,会在你的家目录中的『应用程序』文件夹中创建一个类似快捷方式的替身。

Homebrew Cask 安装

使用命令下载安装

liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew tap phinze/Homebrew Cask && brew install brew-cask
Updating Homebrew...
Error: phinze/cask was moved. Tap homebrew/cask instead.

+++++++++++++++++++++++++++++++++

liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew tap homebrew/cask && brew install brew-cask 
Warning: No available formula or cask with the name "brew-cask". Did you mean brew-pip?
==> Searching for similarly named formulae...
These similarly named formulae were found:
brew-cask-completion ✔                                                                                brew-pip
To install one of them, run (for example):
  brew install brew-cask-completion ✔
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew cask search chrome
Error: Unknown command: cask
liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew -cask search chrome
Error: Unknown command: -cask
liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew --cask search chrome
Error: Unknown command: --cask

++++++++++++++++++++

liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew install  caskroom/cask/brew-cask 
Error: caskroom/cask was moved. Tap homebrew/cask instead.

++++++++++++++++++

liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew tap caskroom/cask && brew install brew-cask
Error: caskroom/cask was moved. Tap homebrew/cask instead.

直接从官网下载安装包

利用官网文件安装

  1. 从官网上下载 Homebrew Cask-master.zip 压缩包,解压后将文件夹名改为 Homebrew Cask
  2. 然后将其拷贝放入 /usr/local/Homebrew/Library/Taps/homebrew 中,与 homebrew-core 文件夹同级
  3. 至此完成 Homebrew Cask 安装

利用国内源手动 clone下载(推荐)

  1. 进入 homebrew 目录:
cd "$(brew --repo)/Library/Taps/homebrew/"
  1. 创建目录 Homebrew Cask
mkdir Homebrew Cask
  1. 开始 clone:
git clone git://mirrors.ustc.edu.cn/Homebrew Cask.git /usr/local/Homebrew/Library/Taps/homebrew/Homebrew Cask

Homebrew Cask 换源

cd "$(brew --repo)/Library/Taps/homebrew/Homebrew Cask"
git remote set-url origin https://mirrors.ustc.edu.cn/Homebrew Cask.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/Homebrew Cask.git
 类似资料: