homebrew-cask/USAGE.md

201 lines
8.1 KiB
Markdown
Raw Normal View History

# How to Use Homebrew Cask
## Frequently Used Commands
2013-11-10 21:36:03 +08:00
2020-11-11 19:12:59 +08:00
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:
2013-12-16 05:08:27 +08:00
* `install` — installs the given Cask.
* `uninstall` — uninstalls the given Cask.
* `reinstall` — reinstalls the given Cask.
* `list --casks` — lists installed Casks.
2013-12-16 05:08:27 +08:00
## Searching for Casks
2013-12-16 05:08:27 +08:00
To search for Casks, use `brew search`. Lets see if theres a Cask for Google Chrome:
2013-12-16 05:08:27 +08:00
```bash
$ brew search google-chrome
==> Casks
2020-11-11 19:12:59 +08:00
google-chrome google-chrome-beta google-chrome-canary google-chrome-dev
```
## Installing Casks
2020-11-11 19:12:59 +08:00
The command `brew install` accepts one or multiple Cask tokens. Lets try to install Google Chrome:
```bash
2020-11-11 19:12:59 +08:00
$ brew install google-chrome
==> Downloading https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
2020-11-11 19:12:59 +08:00
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'google-chrome'.
==> Installing Cask google-chrome
==> Moving App 'Google Chrome.app' to '/Applications/Google Chrome.app'.
🍺 google-chrome was successfully installed!
```
## Uninstalling Casks
Easy peasy:
```bash
2020-11-11 19:12:59 +08:00
$ brew uninstall google-chrome
```
[WIP] Change artifact behavior to moving instead of symlinking (#13966) * Change app artifact to move instead of link First step towards change in installation behavior mentioned in [13201] * Fix handling of binaries linked from inside of app bundles Also adds `appdir` method for interpolation in stanzas * Change appdir to root Applications directory * Update 2-app tests * Refactor: add options, ivars to `Installer`, `Download` In preparation for upcoming changes, this commit cleans up some code. The commit includes: - In order to reduce unnecessary object passing, make both the `force` and `skip_cask_deps` option into instance variables of the `Installer` class - Introduce options hashes to initializers of both the `Installer` and `Download` class - When the `install --force` command enters the fetch phase, make it explicit in the code that fetching is never enforced in that case. - Update tests * Force overwrite artifacts on `--force` reinstall This commit changes the behavior of a `Moved` artifact such that if the target already exists, `brew cask install --force` will remove the existing target before moving the staged artifact. In that case, the warning message will say *overwriting* instead of *not moving*. The behavior of plain `brew cask install` remains unchanged; the same goes for the warning message for that case. * Change remaining artifacts to move instead of symlink * Update casks to use appdir in binary paths * Forcibly overwrite artifacts, modifying flags and using `sudo` if needed - This commit implements [the proposed behavior for `install --force`](https://github.com/caskroom/homebrew-cask/pull/13966#issuecomment-220830387) when a target already exists and has either permission problems or is not owned by the user. - The changes apply only when the `force` option is given. - Reused the existing safeguard from the `.pkg` artifact to prevent deleting important directories by bug or mistake - The two existing blacklists `SYSTEM_DIRS` and `UNDELETABLE_DIRS` have been consolidated into the `Hbc::MacOS` module. - `UNDELETABLE_DIRS` now also contains all the entries from `SYSTEM_DIRS` which was a to-do anyway. - The two blacklists are now also frozen for good measure. - The utility method `permissions_rmtree` was moved to `Hbc::Utils`. - The `tried_permissions` part in `Utils` now falls back correctly when there are also ownership issues at the same time. - Introduced a separate `current_user` method for mocking. - Added an optional feature to `FakeSystemCommand` so it can now act as a proxy to `SystemCommand`. - Added tests for various `permissions_rmtree` cases.
2016-06-01 03:23:21 +08:00
This will both uninstall the Cask and remove applications which were moved to `/Applications`.
## Other Commands
* `info` — displays information about the given Cask.
* `fetch` — downloads remote application files for the given Cask to the local cache (with `--force`, re-download even if already cached).
* `--cache` — displays the path to Homebrew's local cache.
* `doctor` — checks for configuration issues.
* `style` — checks Cask style using RuboCop.
* `home` — opens the homepage of the given Cask; or with no arguments, the Homebrew project page.
* `uninstall --zap` — try to remove *all* files associated with a Cask (may include resources shared with other applications).
* `outdated` — lists all outdated Casks.
* `upgrade` — updates all outdated Casks.
The following commands are for Cask authors:
* `audit` — verifies installability of Casks.
* `cat` — dumps the given Cask to the standard output.
* `create --cask` — creates a Cask and opens it in an editor.
* `edit` — edits the given Cask.
The following aliases and abbreviations are provided for convenience:
2015-09-07 21:33:37 +08:00
* `ls``list`
* `-S``search`
* `rm`, `remove``uninstall`
* `dr``doctor`
2020-11-11 19:12:59 +08:00
* `abv``info`
* `homepage``home`
2015-10-23 12:29:12 +08:00
## Tab Completion
2020-11-11 19:12:59 +08:00
Homebrew Cask comes with `bash` and `zsh` completion for the `brew` command.
2015-10-23 12:29:12 +08:00
2018-06-22 22:09:22 +08:00
See https://docs.brew.sh/Shell-Completion for more information.
2015-10-23 12:29:12 +08:00
2018-06-22 22:09:22 +08:00
`fish` completions can be installed with:
2015-10-23 12:29:12 +08:00
```bash
2018-06-22 22:09:22 +08:00
$ brew install brew-cask-completion
2015-10-23 12:29:12 +08:00
```
## Inspecting Installed Casks
2016-01-11 20:00:37 +08:00
List all installed Casks:
```bash
2020-11-11 19:12:59 +08:00
$ brew list --casks
atom google-chrome 1password
```
2020-11-11 19:12:59 +08:00
With `--full-name` the Tap name will also be included, _e.g._: `purple/monkey/dishwasher` for the Cask `dishwasher` installed from the Tap `purple/monkey`.
Given an installed Cask, `brew list --casks <cask_name>` lists the staged files.
2020-11-11 19:12:59 +08:00
Show details about a specific Cask:
```bash
2020-11-11 19:12:59 +08:00
$ brew info keepingyouawake
Error: No available formula with the name "keepingyouawake"
Found a cask named "keepingyouawake" instead.
keepingyouawake: 1.5.2 (auto_updates)
https://keepingyouawake.app/
/usr/local/Caskroom/keepingyouawake/1.5.2 (129B)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/keepingyouawake.rb
2016-08-15 07:35:03 +08:00
==> Name
2020-11-11 19:12:59 +08:00
KeepingYouAwake
==> Description
Prevents your computer from going to sleep
2016-08-15 07:35:03 +08:00
==> Artifacts
2020-11-11 19:12:59 +08:00
KeepingYouAwake.app (App)
```
## Updating/Upgrading Casks
2020-11-11 19:12:59 +08:00
Since the Homebrew Cask repository is a Homebrew Tap, youll pull down the latest Casks every time you issue the regular Homebrew command `brew update`. You can check for outdated Casks with `brew outdated` and install the outdated Casks with `brew upgrade`. Many applications update themselves, so their Casks are ignored by `brew outdated` and `brew upgrade`. This behaviour can be overridden by adding `--greedy` to the command.
## Updating/Upgrading the Homebrew Cask Tool
Homebrew [automatically taps and keeps Homebrew Cask updated](https://github.com/Homebrew/homebrew-cask/pull/15381). `brew update` is all that is required.
## Additional Taps (optional)
The primary Homebrew Cask Tap includes most of the Casks that a typical user will be interested in. There are a few additional Taps where we store different kinds of Casks.
| Tap name | description |
| -------- | ----------- |
2020-11-11 19:12:59 +08:00
| [Homebrew/cask-versions](https://github.com/Homebrew/homebrew-cask-versions) | contains alternate versions of Casks (_e.g._ betas, nightly releases, old versions)
2018-05-22 03:21:38 +08:00
| [Homebrew/cask-fonts](https://github.com/Homebrew/homebrew-cask-fonts) | contains Casks that install fonts
| [Homebrew/cask-drivers](https://github.com/Homebrew/homebrew-cask-drivers) | contains Casks that install drivers for various devices
You can tap any of the above with a `brew tap` command:
```bash
$ brew tap <tap_name>
```
2015-09-16 06:24:11 +08:00
after which, Casks from the new Tap will be available to `search` or `install` just like Casks from the main Tap. `brew update` will automatically keep your new Tap up to date.
2020-11-11 19:12:59 +08:00
You may also specify a fully-qualified Cask token (which includes the Tap) for any `brew` command. This will implicitly add the Tap if you have not previously added it with `brew tap`:
```bash
2020-11-11 19:12:59 +08:00
$ brew install homebrew/cask-fonts/font-symbola
```
## Options
2020-11-11 19:12:59 +08:00
`brew` accepts a number of options:
2014-01-06 04:30:53 +08:00
* `--version`: print version and exit.
* `--debug`: output debug information.
* `--no-binaries`: skip symlinking executable binaries into `/usr/local/bin`.
* `--require-sha`: abort installation of Cask if no checksum is defined.
* `--no-quarantine`: [disable Apples quarantining](https://docs.brew.sh/FAQ#why-cant-i-open-a-mac-app-from-an-unidentified-developer) for the specific app.
2020-11-11 19:12:59 +08:00
* `--language=<iso-language>[,<iso-language> ... ]`: changes the language of the Cask to be installed. The first matching language is used, otherwise it uses the default language of the Cask.
2014-01-06 04:30:53 +08:00
2020-11-11 19:12:59 +08:00
You can also modify the default installation locations used when issuing `brew install`:
* `--appdir=/my/path` changes the path where the applications will be moved. Default is `/Applications`.
* `--fontdir=/my/path` changes the path for Fonts. Default is `~/Library/Fonts`.
2014-01-28 23:17:50 +08:00
2020-11-11 19:12:59 +08:00
See `man brew` for the other default installation locations and the flags to change them.
To make these settings persistent, you might want to add the following line to your `.profile`, `.bash_profile` or `.zprofile`:
```bash
2013-12-14 17:10:50 +08:00
# Specify your defaults in this environment variable
export HOMEBREW_CASK_OPTS="--appdir=~/Applications --fontdir=/Library/Fonts"
```
2015-09-16 06:24:11 +08:00
Note that you still can override the environment variable `HOMEBREW_CASK_OPTS` by _explicitly_ providing options in the command line:
```bash
# Will force the Chrome app to be moved to /Applications
[WIP] Change artifact behavior to moving instead of symlinking (#13966) * Change app artifact to move instead of link First step towards change in installation behavior mentioned in [13201] * Fix handling of binaries linked from inside of app bundles Also adds `appdir` method for interpolation in stanzas * Change appdir to root Applications directory * Update 2-app tests * Refactor: add options, ivars to `Installer`, `Download` In preparation for upcoming changes, this commit cleans up some code. The commit includes: - In order to reduce unnecessary object passing, make both the `force` and `skip_cask_deps` option into instance variables of the `Installer` class - Introduce options hashes to initializers of both the `Installer` and `Download` class - When the `install --force` command enters the fetch phase, make it explicit in the code that fetching is never enforced in that case. - Update tests * Force overwrite artifacts on `--force` reinstall This commit changes the behavior of a `Moved` artifact such that if the target already exists, `brew cask install --force` will remove the existing target before moving the staged artifact. In that case, the warning message will say *overwriting* instead of *not moving*. The behavior of plain `brew cask install` remains unchanged; the same goes for the warning message for that case. * Change remaining artifacts to move instead of symlink * Update casks to use appdir in binary paths * Forcibly overwrite artifacts, modifying flags and using `sudo` if needed - This commit implements [the proposed behavior for `install --force`](https://github.com/caskroom/homebrew-cask/pull/13966#issuecomment-220830387) when a target already exists and has either permission problems or is not owned by the user. - The changes apply only when the `force` option is given. - Reused the existing safeguard from the `.pkg` artifact to prevent deleting important directories by bug or mistake - The two existing blacklists `SYSTEM_DIRS` and `UNDELETABLE_DIRS` have been consolidated into the `Hbc::MacOS` module. - `UNDELETABLE_DIRS` now also contains all the entries from `SYSTEM_DIRS` which was a to-do anyway. - The two blacklists are now also frozen for good measure. - The utility method `permissions_rmtree` was moved to `Hbc::Utils`. - The `tried_permissions` part in `Utils` now falls back correctly when there are also ownership issues at the same time. - Introduced a separate `current_user` method for mocking. - Added an optional feature to `FakeSystemCommand` so it can now act as a proxy to `SystemCommand`. - Added tests for various `permissions_rmtree` cases.
2016-06-01 03:23:21 +08:00
# even though HOMEBREW_CASK_OPTS specified ~/Applications
2020-11-11 19:12:59 +08:00
$ brew install --appdir="/Applications" google-chrome
```
## Other Ways to Specify a Cask
2020-11-11 19:12:59 +08:00
Most `brew` commands can accept a Cask token as an argument. As described above, the token on the command line can take the form of:
2020-11-11 19:12:59 +08:00
* A simple token, _e.g._: `google-chrome`.
* A fully-qualified token which includes the Tap, _e.g._: `homebrew/cask/google-chrome`.
2020-11-11 19:12:59 +08:00
`brew` also accepts three other forms as arguments:
2020-11-11 19:12:59 +08:00
* A path to a Cask file, _e.g._: `/usr/local/Library/Taps/homebrew/homebrew-cask/Casks/google-chrome.rb`.
* A `curl`-retrievable URI to a Cask file, _e.g._: `https://raw.githubusercontent.com/Homebrew/homebrew-cask/f25b6babcd398abf48e33af3d887b2d00de1d661/Casks/google-chrome.rb`.
* A file in the current working directory, _e.g._: `my-modfied-google-chrome.rb`. Note that matching Tapped Cask tokens will be preferred over this form when there is a conflict. To force the use of a Cask file in the current directory, specify a pathname with slashes, _e.g._: `./google-chrome.rb`.
The last three forms are intended for users who wish to maintain private Casks.
## Taps
2015-09-16 06:24:11 +08:00
You can add Casks to your existing (or new) Taps: just create a directory named `Casks` inside your Tap, put your Cask files there, and everything will just work.