18 KiB
Homebrew
:fa-link: https://docs.brew.sh
Update Homebrew et les formules:
$ brew update
Chercher les M-à-J:
$ brew outdated
# --verbose
Mettre tout à jour:
$ brew upgrade
# --cleanup Met à jour et supprime les anciennes versions installées.
Formules:
Mettre à jour une formule:
$ brew upgrade <formula>
# --cleanup Met à jour et supprime les anciennes versions installées.
Installer une formule:
$ brew install <formula>
$ brew install --verbose --debug <formula>
# --build-from-source Compile la formule depuis la source même si une bottle est disponible. Les dépendances sont installées depuis les bottles.
Installer une formule d’ailleurs la branche:
$ brew install https://raw.github.com/user/repo/branch/formula.rb
Reinstaller une formule depuis les sources:
$ brew reinstall -s <formula>
Desinstaller une formule:
$ brew uninstall <formula>
# --force toutes les versions de la formule seront effacées
# --ignore-dependencies desinstallera même si des dépendances restent installées
Desinstaller les anciennes versions d’une formule:
$ brew cleanup <formula>
# Supprime toutes les anciennes dans la Cellar et dans le Cache.
# --dry-run (ou -n) montre ce qui va être supprimer mais n'enlève rien.
# --prune=days supprime les fichiers du Cache plus vieux que <days> jours.
Desinstaller toutes les anciennes versions:
$ brew cleanup
# (-n ou --dry-run) voir tout ce qui sera désinstaller
Empecher la m-à-j d’un package:
$ brew pin <formula>
bruno@SilverBook:/usr/local/Cellar/terminal-notifier/1.8.0$ brew pin terminal-notifier
$ brew pin php
$ brew info php
php: stable 7.4.0 (bottled) [pinned at 7.3.12]
Liste des paquets 'pinned':
$ brew list --pinned
php
Essayer de mettre-à-jour un paquet 'pinned':
$ brew upgrade -n php
Error: Not upgrading 1 pinned package:
php 7.4.0
==> No packages to upgrade
Re-permettre la m-à-j:
$ brew unpin <formula>
Liste des formules installées:
$ brew list
# --versions affiche la verion en plus.
# --pinned affiche les formules pinned
Afficher des infos sur une formule installée:
$ brew info <formula>
$ brew info terminal-notifier
terminal-notifier: stable 1.8.0 (bottled), HEAD
Send macOS User Notifications from the command-line
https://github.com/julienXX/terminal-notifier
/usr/local/Cellar/terminal-notifier/1.7.1 (14 files, 2MB)
Poured from bottle on 2016-10-19 at 07:24:46
/usr/local/Cellar/terminal-notifier/1.8.0 (5 files, 99.8KB) *
Poured from bottle on 2017-08-12 at 20:20:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/terminal-notifier.rb
==> Requirements
Build: xcode ✔
Required: macOS >= 10.8 ✔
Description d'une formule:
$ brew desc <formula>
$ brew desc httpd
httpd: Apache HTTP server
Afficher les options d'une formule:
$ brew options <formula>
$ brew options php72
--with-argon2
Include libargon2 password hashing support
--with-cgi
Enable building of the CGI executable (implies --without-fpm)
--with-debug
Compile with debugging symbols
# --compact sur une seule ligne
Chercher une formule (avec description):
$ brew search --desc <formula>
$ brew search --desc pdf
briss: Crop PDF files
diff-pdf: Visually compare two PDF files
Activer une autre version:
$ brew switch <formula>
bruno@SilverBook:/usr/local/Cellar/terminal-notifier/1.8.0$ brew switch terminal-notifier 1.7.1
Cleaning /usr/local/Cellar/terminal-notifier/1.7.1
Cleaning /usr/local/Cellar/terminal-notifier/1.8.0
1 links created for /usr/local/Cellar/terminal-notifier/1.7.1
Installer une ancienne version d'une formule:
Exemple avec annie, un téléchargeur de vidéo. La version courante est la dernière (0.9.6)
~ master*
❯ annie -v
annie: version 0.9.6, A fast, simple and clean video downloader.
~ master*
❯ cd "$(brew --repo homebrew/core)"
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core master
❯ git log Formula/annie.rb
commit 377c142a619f2b2563c4c01b06f2560707fa3228
Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
Date: Fri Nov 8 10:23:24 2019 +0000
annie: update 0.9.6 bottle.
commit e3201eb44c3eade6f113f616b67315ae13f5a70b
Author: iawia002 <xuxinzhao@caicloud.io>
Date: Fri Nov 8 18:15:49 2019 +0800
annie 0.9.6
Closes #46491.
Signed-off-by: Rui Chen <rchen@meetup.com>
commit ef762f724ce45afb0007f7d3b96a8f10ceeb3b58
Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
Date: Fri Oct 11 21:56:45 2019 +0000
annie: update 0.9.5 bottle.
commit 249669ab6a53335d85d8973c8e82f182903434ca
Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
Date: Tue Aug 13 14:30:19 2019 +0000
annie: update 0.9.5 bottle.
commit 5fa1c6903f84cc22c2cbed751de6125cab4fe214
Author: iawia002 <xuxinzhao@caicloud.io>
Date: Tue Aug 13 22:22:21 2019 +0800
annie 0.9.5
Closes #43069.
Signed-off-by: Thierry Moisan <thierry.moisan@gmail.com>
Création d'une nouvelle branche pour l'ancienne version:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core master 19s
❯ git checkout -b annie-0.9.5 ef762f724ce45afb0007f7d3b96a8f10ceeb3b58
Basculement sur la nouvelle branche 'annie-0.9.5'
Unlink la version courante:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core annie-0.9.5
❯ brew unlink annie
Unlinking /usr/local/Cellar/annie/0.9.6... 1 symlinks removed
Installation de la version 0.9.5:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core annie-0.9.5
❯ HOMEBREW_NO_AUTO_UPDATE=1 brew install annie
==> Downloading https://homebrew.bintray.com/bottles/annie-0.9.5.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/06/06ff55a2834ad01a262b66f181a8c99800157ec0f465f80e0cc3518be7ebd1da?__gda__=exp=1575195423~hmac=edc063962f1a5b12a715444b0f1eff
######################################################################## 100.0%
==> Pouring annie-0.9.5.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/annie/0.9.5: 5 files, 8.6MB
L'ancienne version 0.9.5 est bien active:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core annie-0.9.5
❯ annie -v
annie: version 0.9.5, A fast, simple and clean video downloader.
Retour sur la branche 'master'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core annie-0.9.5
❯ git checkout master
Basculement sur la branche 'master'
Votre branche est à jour avec 'origin/master'.
Suppression de l'ancienne branche 0.9.5
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core master
❯ git branch -d annie-0.9.5
Branche annie-0.9.5 supprimée (précédemment ef762f72).
Liste des versions installés:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core master
❯ brew list annie --versions
annie 0.9.6 0.9.5
Info sur la formule 'annie'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core master
❯ brew info annie
annie: stable 0.9.6 (bottled)
Fast, simple and clean video downloader
https://github.com/iawia002/annie
/usr/local/Cellar/annie/0.9.5 (5 files, 8.6MB) *
Poured from bottle on 2019-12-01 at 11:05:06
/usr/local/Cellar/annie/0.9.6 (5 files, 8.6MB)
Poured from bottle on 2019-12-01 at 10:57:11
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/annie.rb
Changement de version:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core master
❯ brew switch annie 0.9.6
Cleaning /usr/local/Cellar/annie/0.9.6
Cleaning /usr/local/Cellar/annie/0.9.5
1 links created for /usr/local/Cellar/annie/0.9.6
Configurer (arguments) une formule:
$ brew edit <formula>
Afficher la homepage de Homebrew:
$ brew home
Afficher la homepage de la formule:
$ brew home <formula>
Log:
$ brew log <formula>
« keg-only »
La formule est installée dans Cellar. Elle n’est pas linkée dans /usr/local (elle n'est pas appelable directement, faire /usr/local/my-command_keg-only)
Pour la linker:
$ brew link
Changer de version de PHP:
$ brew unlink php54 && brew link php53
Dépendances:
Voir les dépendances:
$ brew deps <formula>
$ brew deps httpd
apr
apr-util
boost
c-ares
jansson
jemalloc
libev
libevent
nghttp2
openssl
pcre
# --tree Présentation comme arbre
Montrer les formules installées qui ne sont pas des dépendances d'autres formules installées:
$ brew leaves
Montrer les dépendances manquantes:
$ brew missing
$ brew missing <formula>
Dépendances inverses:
$ brew uses x264 --installed
ffmpeg
$ brew list -1 | while read cask; do echo -ne "\x1B[1;34m $cask \x1B[0m"; brew uses $cask --installed | awk '{printf(" %s ", $0)}'; echo ""; done
ack
aom ffmpeg
apr apr-util httpd php php@7.2
.../...
x264 ffmpeg
Outils:
Vérifier le système:
$ brew doctor
Prune (supprimer les liens symboliques morts):
$ brew prune
# --dry-run
Où va tout ce que télécharge Homebrew (cache):
$ brew --cache
/Users/bruno/Library/Caches/Homebrew
$ cd /Users/bruno/Library/Caches/Homebrew
total 2616544
drwxr-xr-x 92 bruno staff 2944 17 jan 17:19 .
drwx------+ 194 bruno staff 6208 18 jan 18:57 ..
drwxr-xr-x 11 bruno staff 352 18 jan 18:54 Cask
-rw-r--r-- 1 bruno staff 400053 28 oct 08:20 apr-1.6.3.high_sierra.bottle.tar.gz
-rw-r--r-- 1 bruno staff 242481 3 nov 02:01 apr-util-1.6.1_1.high_sierra.bottle.tar.gz
-rw-r--r-- 1 bruno staff 88679443 19 déc 10:23 boost-1.66.0.high_sierra.bottle.tar.gz
-rw-r--r-- 1 bruno staff 3434 16 déc 20:15 brew-pip-0.4.1.tar.gz
-rw-r--r-- 1 bruno staff 12310915 21 nov 13:01 cmake-3.10.0.high_sierra.bottle.tar.gz
Affiche le chemin de Cellar:
$ brew --Cellar
/usr/local/Cellar
$ brew --Cellar httpd
/usr/local/Cellar/httpd
Sauvegarder sa configuration Homebrew:
Liste des packages, taps et casks installés:
$ brew tap Homebrew/bundle
$ brew bundle dump
Ceci crée un fichier Brewfile que l'on peut éditer.
tap 'homebrew/php'
brew 'homebrew/php/php71', args: ['with-imap']
brew 'shpotify'
cask 'spotify'
Restaurer sa configuration:
# Se positionner dans le répertoire contenant le fichier Brewfile
$ brew bundle
Services:
Liste des services gérés par brew services:
bruno@SilverBook:~$ brew services list
Name Status User Plist
mariadb started bruno /Users/bruno/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
php71 started bruno /Users/bruno/Library/LaunchAgents/homebrew.mxcl.php71.plist
httpd started root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
Lancer au démarrage:
$ brew services start mysql
Démarrer (pas au boot):
$ brew services run mysql
Arrêter le service:
$ brew services stop mysql
Redémarrer le service:
$ brew services restart mysql
Taps (third-party repositories):
:fa-link: brew tap rajoute des repositories à brew
Liste les repos tapped:
$ brew tap
caskroom/cask
homebrew/apache
homebrew/core
homebrew/dupes
homebrew/php
homebrew/services
homebrew/versions
tideways/profiler
vapor/tap
Les tap sont situés là:
bruno@silverbook:/usr/local/Homebrew/Library/Taps$ ls
caskroom homebrew tideways vapor
Ajouter un repo:
$ brew tap <tapname>
Supprimer un repo:
$ brew untap <tapname>
Commandes externes:
brew caveats:
Affiche les avertissements pour toutes les formules installées.
$ brew tap zgracem/caveats
$ brew caveats
==> libtool
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==> lua
You may also want luarocks:
brew install luarocks
==> mariadb
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
To connect:
mysql -uroot
To have launchd start mariadb now and restart at login:
brew services start mariadb
Or, if you don't want/need a background service you can just run:
mysql.server start
==> mono
To use the assemblies from other formulae you need to set:
export MONO_GAC_PREFIX="/usr/local"
Environnement:
-
HOMEBREW_AUTO_UPDATE_SECS: If set, Homebrew will only check for autoupdates once per this seconds interval.Default:
300. -
HOMEBREW_GITHUB_API_TOKEN: A personal access token for the GitHub API, used by Homebrew for features such asbrew search. You can create one at https://github.com/settings/tokens. If set, GitHub will allow you a greater number of API requests. For more information, see: https://developer.github.com/v3/#rate-limitingNote: Homebrew doesn’t require permissions for any of the scopes.
-
HOMEBREW_NO_AUTO_UPDATE: If set, Homebrew will not auto-update before runningbrew install,brew upgradeorbrew tap. -
HOMEBREW_VERBOSE: If set, Homebrew always assumes--verbosewhen running commands.
coreutils (GNU Tools)
Installer la version GNU des outils lignes de commande (OSX utilise la version BSD):
$ brew install coreutils
Les outils GNU sont préfixés par la lettre g (gls, gcat, gchmod...), permettant d'utiliser également leur pendant BSD (ls, cat, chmod...)
Les outils GNU sont installés dans /usr/local/bin/
Un alias sans le préfixe g est crée dans /usr/local/opt/coreutils/libexec/gnubin/
On peut ajouter le dossier /usr/local/opt/coreutils/libexec/gnubin dans le $PATH. Les outils GNU sont alors disponibles sans préfixe, à la place des outils BSD.
De même pour les man (MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH")
# AVEC PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
❯ which ls
/usr/local/opt/coreutils/libexec/gnubin/ls
❯ which gls
/usr/local/bin/gls
(gls -> ../Cellar/coreutils/8.31/bin/gls)
❯ which /bin/ls
/bin/ls
❯ ls --version
ls (GNU coreutils) 8.31
❯ gls --version
ls (GNU coreutils) 8.31
# SANS PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
❯ which ls
/bin/ls
❯ which gls
/usr/local/bin/gls
❯ which /bin/ls
/bin/ls
❯ ls --version
ls: illegal option -- -
❯ gls --version
ls (GNU coreutils) 8.31
findutils (GNU Tools)
Comprend les versions GNU de find, locate, xargs (pas de updatedb dans osx )
$ brew install findutils
# SANS PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
$ which find
/usr/bin/find
$ which gfind
/usr/local/bin/gfind
$ gfind --version
find (GNU findutils) 4.7.0
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)
Ajouter PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" et PATH="/usr/local/opt/findutils/libexec/gnuman:$PATH" au $PATH pour accéder aux commandes sans le préfixe g.
Autres paquets GNU:
- gnu-getopt (keg-only)
- gnutls
- grep (ggrep)(
PATH="/usr/local/opt/grep/libexec/gnubin:$PATH") - moreutils (https://joeyh.name/code/moreutils/)
- gnu-sed
- gawk
- gnu-tar
- ...
Erreurs:
`require': cannot load such file -- active_support/core_ext/object/blank (LoadError)
# Erreur sur chaque commande brew...
% brew doctor
Traceback (most recent call last):
4: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'
3: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
2: from /usr/local/Homebrew/Library/Homebrew/global.rb:13:in `<top (required)>'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- active_support/core_ext/object/blank (LoadError)
Lancer brew update-reset pour réparer:
% brew update-reset
==> Fetching /usr/local/Homebrew...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 38 (delta 5), reused 31 (delta 2), pack-reused 0
Unpacking objects: 100% (38/38), done.
From https://github.com/Homebrew/brew
* [new branch] dependabot/bundler/Library/Homebrew/rubocop-rspec-1.37.0 -> origin/dependabot/bundler/Library/Homebrew/rubocop-rspec-1.37.0
==> Resetting /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.
==> Fetching /usr/local/Homebrew/Library/Taps/getantibody/homebrew-tap...
==> Resetting /usr/local/Homebrew/Library/Taps/getantibody/homebrew-tap...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.