-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
base: master
Are you sure you want to change the base?
Conversation
Inspired by @jvns' [post][1], I realized that I've had this problem on multiple teams, where someone missed the step at the end and didn't know how to recover. Typically, I've provided a version like what I've added to the Tips 'n' Tricks page so that I didn't have to think about what OS-arch pair my users are using. I've tested the loader added to tips and tricks with both bash and zsh and it passes both shellcheck and shfmt in posix mode. [1]: https://mastodon.social/@[email protected]/113997565198024027
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do this in my cross-platform startup files:
case "$(uname -sm)" in
# Intel macOS
"Darwin x86_64") HOMEBREW_PREFIX="/usr/local";;
# M-series ARM64 macOS
"Darwin arm64") HOMEBREW_PREFIX="/opt/homebrew";;
# Linux
"Linux "*) HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";;
*) echo "Warning: Homebrew is not supported on this platform." >&2;;
esac
The default case is optional, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, yeah, I should golf my example down to that.
When I set this up for myself several few years ago, I checked directories' and files' existence instead of looking at uname output: https://github.com/colindean/hejmo/blame/35b40129563c27be051d316cc67a7fdcccb93daf/bash_profile/00_path.sh#L4-L18
(I'm also looking at that file casually for the first time in many years and realizing there's more stuff hardcoded to /usr/local than should be!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it may not: fish's case
syntax is different than zsh/bash, and the above is POSIX-compliant, good enough for docs.
Co-authored-by: Eric Knibbe <[email protected]>
|
||
where `${HOMEBREW_PREFIX}` is the Homebrew installation directory. | ||
Replace this with the installation directory on your system. | ||
See the [FAQ about default installation locations](FAQ.md#why-should-i-install-homebrew-in-the-default-location). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked my friend who inspired the original post and they said they found this section extremely difficult to understand. We tried to rework it to make it clearer and this is what we came up with:
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:
eval "<Homebrew prefix path>/bin/brew shellenv)"
Replace <Homebrew prefix path>
with the directory where Homebrew is installed on your system. You can find Homebrew's default install location in this FAQ entry.
Inspired by @jvns' post, I realized that I've had this problem on multiple teams, where someone missed the step at the end and didn't know how to recover. Typically, I've provided a version like what I've added to the Tips 'n' Tricks page so that I didn't have to think about what OS-arch pair my users are using.
I've tested the loader added to tips and tricks with both bash and zsh and it passes both shellcheck and shfmt in posix mode.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?