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 4 commits into
base: master
Choose a base branch
from

Conversation

colindean
Copy link
Contributor

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.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

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
docs/Installation.md Outdated Show resolved Hide resolved
Comment on lines +153 to +166
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
Copy link
Contributor

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.

Copy link
Contributor Author

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!)

Copy link
Contributor Author

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.


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).
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants