Use proper homebrew prefix and add to path (#602)

Closes #589 

This adds support for properly installing Homebrew on either Apple Silicon or Intel machines to the correct Homebrew location on macOS.

Also changes to:
* Using `HEAD` instead of `master`, which comes from the Homebrew home page.
* Use the new  `shellenv` recommended by Homebrew post-install next steps.
trunk
Chad Pytel 2 years ago committed by GitHub
parent f538968566
commit 618d208e45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

23
mac

@ -46,16 +46,12 @@ fi
# shellcheck disable=SC2016
append_to_zshrc 'export PATH="$HOME/.bin:$PATH"'
HOMEBREW_PREFIX="/usr/local"
if [ -d "$HOMEBREW_PREFIX" ]; then
if ! [ -r "$HOMEBREW_PREFIX" ]; then
sudo chown -R "$LOGNAME:admin" /usr/local
fi
# Determine Homebrew prefix
arch="$(uname -m)"
if [ "$arch" = "arm64" ]; then
HOMEBREW_PREFIX="/opt/homebrew"
else
sudo mkdir "$HOMEBREW_PREFIX"
sudo chflags norestricted "$HOMEBREW_PREFIX"
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX"
HOMEBREW_PREFIX="/usr/local"
fi
update_shell() {
@ -92,14 +88,11 @@ gem_install_or_update() {
if ! command -v brew >/dev/null; then
fancy_echo "Installing Homebrew ..."
/bin/bash -c \
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
append_to_zshrc '# recommended by brew doctor'
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# shellcheck disable=SC2016
append_to_zshrc 'export PATH="/usr/local/bin:$PATH"' 1
append_to_zshrc "eval \"\$($HOMEBREW_PREFIX/bin/brew shellenv)\""
export PATH="/usr/local/bin:$PATH"
export PATH="$HOMEBREW_PREFIX/bin:$PATH"
fi
if brew list | grep -Fq brew-cask; then

Loading…
Cancel
Save