diff --git a/docs/Installation.md b/docs/Installation.md index 959585a1189e8..cf90ebed016a5 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -93,6 +93,26 @@ 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 + +When you install Homebrew, it prints some directions for updating your shell's config. +If you don't follow those directions, Homebrew will not work. + +You need to update your shell's config file (which file exactly depends on your shell, for example `~/.bashrc` or `~/.zshrc`) to include this: + +```sh +eval "/bin/brew shellenv)" +``` + +Replace `` with the directory where Homebrew is installed on your system. +You can find Homebrew's default install location [in this FAQ entry](https://docs.brew.sh/FAQ#why-should-i-install-homebrew-in-the-default-location). + +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). diff --git a/docs/Tips-N'-Tricks.md b/docs/Tips-N'-Tricks.md index 85dde92c8629d..ea2ce64612758 100644 --- a/docs/Tips-N'-Tricks.md +++ b/docs/Tips-N'-Tricks.md @@ -140,3 +140,14 @@ 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 +command -v brew || export PATH="/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin" +command -v brew && eval "$(brew shellenv)" +```