Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds post-installation steps to installation with extend version in tips #19304

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ Make sure you avoid installing into:

Create a Homebrew installation wherever you extract the tarball. Whichever `brew` command is called is where the packages will be installed. You can use this as you see fit, e.g. to have a system set of libs in the default prefix and tweaked formulae for development in `~/homebrew`.

## Post-installation steps

Before completing installation, Homebrew installer will provide some required "Next steps" instructions.
These instructions configure your shell to evaluate the output of `brew shellenv`,
which will load `brew` into your shell environment for use.

While it's difficult to document the precise path for every shell,
typically, what follows must be in your shell's `rc` or `profile` file:

```sh
eval "${HOMEBREW_PREFIX}/bin/brew shellenv)"
colindean marked this conversation as resolved.
Show resolved Hide resolved
```

where `${HOMEBREW_PREFIX}` is the Homebrew installation directory.
Replace this with the installation directory on your system.
colindean marked this conversation as resolved.
Show resolved Hide resolved

For more insight, re-run the installer or inspect [the installer's source](https://github.com/Homebrew/install/blob/deacfa6a6e62e5f4002baf9e1fac7a96e9aa5d41/install.sh#L1072-L1088)
to see how the installer constructs the path it recommends.

See [Tips N' Tricks > Loading Homebrew from the same dotfiles on different operating systems](Tips-N'-Tricks.md#loading-homebrew-from-the-same-dotfiles-on-different-operating-systems)
for another way to handle this across multiple operating systems.

## Uninstallation

Uninstallation is documented in the [FAQ](FAQ.md#how-do-i-uninstall-homebrew).
Expand Down
39 changes: 39 additions & 0 deletions docs/Tips-N'-Tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,42 @@ export HOMEBREW_ARTIFACT_DOMAIN=https://artifacts.example.com/artifactory/homebr
export HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK=1
export HOMEBREW_DOCKER_REGISTRY_BASIC_AUTH_TOKEN="$(printf 'anonymous:' | base64)"
```

## Loading Homebrew from the same dotfiles on different operating systems

Some users may want to use the same shell initialization files on macOS and Linux.
Use this to detect the likely Homebrew installation directory and load Homebrew when it's found.
You may need to adapt this to your particular shell or other particulars of your environment.

```sh
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
# Execute only if brew isn't already available.
if ! [ -x "$(command -v brew)" ]; then
OS="$(uname)"
UNAME_MACHINE="$(uname -m)"
if [ "${OS}" = "Linux" ]; then
# Linux
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
elif [ "${OS}" = "Darwin" ]; then
if [ "${UNAME_MACHINE}" = "arm64" ]; then
# M-series ARM64 macOS
HOMEBREW_PREFIX="/opt/homebrew"
else
# Intel macOS
HOMEBREW_PREFIX="/usr/local"
fi
fi
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved

if [ -d "${HOMEBREW_PREFIX}" ]; then
BREW_BIN="${HOMEBREW_PREFIX}/bin/brew"
if [ -x "${BREW_BIN}" ]; then
eval "\$(${BREW_BIN} shellenv)"
else
>&2 printf "Homebrew possibly found at %s but %s is not executable. Check the permissions.\n" "${HOMEBREW_PREFIX}" "${BREW_BIN}"
fi
else
>&2 printf "Homebrew not found where expected in %s on %s %s\n" "${HOMEBREW_PREFIX}" "${OS}" "${UNAME_MACHINE}"
>&2 printf "Double-check that it's installed or run the following command to install it\n\n\t%s\n" \
'/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
fi
fi
Comment on lines +151 to +180
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Execute only if brew isn't already available.
if ! [ -x "$(command -v brew)" ]; then
OS="$(uname)"
UNAME_MACHINE="$(uname -m)"
if [ "${OS}" = "Linux" ]; then
# Linux
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
elif [ "${OS}" = "Darwin" ]; then
if [ "${UNAME_MACHINE}" = "arm64" ]; then
# M-series ARM64 macOS
HOMEBREW_PREFIX="/opt/homebrew"
else
# Intel macOS
HOMEBREW_PREFIX="/usr/local"
fi
fi
if [ -d "${HOMEBREW_PREFIX}" ]; then
BREW_BIN="${HOMEBREW_PREFIX}/bin/brew"
if [ -x "${BREW_BIN}" ]; then
eval "\$(${BREW_BIN} shellenv)"
else
>&2 printf "Homebrew possibly found at %s but %s is not executable. Check the permissions.\n" "${HOMEBREW_PREFIX}" "${BREW_BIN}"
fi
else
>&2 printf "Homebrew not found where expected in %s on %s %s\n" "${HOMEBREW_PREFIX}" "${OS}" "${UNAME_MACHINE}"
>&2 printf "Double-check that it's installed or run the following command to install it\n\n\t%s\n" \
'/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
fi
fi
command -v brew || export PATH="/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin"
command -v brew && eval "$(brew shellenv)"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colindean This seems sufficient to handle all platforms without error output and is short and easier to understand.

For future: can you allow maintainers to commit to your fork? Thanks.

```
Loading