dotfiles
dotfiles copied to clipboard
Brew: Command not found Error 127
Sparkling fresh MacOs install on a sparking fresh MBP here, cloned to ~/.dotfiles/
and ran make
from the dotfiles directory but looks like homebrew isn't making it into PATH
? I'm trying to step though the Makefile but with a dozen tabs open, my command of make
is more like a weak suggestion. I'll update here if I figure something out.
==> Downloading and installing Homebrew...
HEAD is now at 17e9adef2 Merge pull request #13337 from Homebrew/dependabot/bundler/Library/Homebrew/parallel_tests-3.11.0
Updated 1 tap (homebrew/core).
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/atp/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh
if ! grep -q /opt/homebrew/bin/bash /private/etc/shells; then \
brew install bash bash-completion@2 pcre && \
sudo append /opt/homebrew/bin/bash /private/etc/shells && \
chsh -s /opt/homebrew/bin/bash; \
fi
/bin/bash: brew: command not found
make: *** [bash] Error 127
For extra context, this issue is easily leap frogged by manually running the commands brew asks you to run to make sure brew works:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/[USERNAME]/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
but a major reason I'm drawn to using dotfiles is the ability to go from brand spankin new machine to ready to work machine in as few commands as possible. Also to better understand what's going on in this Makefile and Makefiles in general 😃
So, it looks eventually the issue was that brew
could not be found in PATH
. The cleanup task in the CI workflow does not exactly get into this sparkling fresh macOS state, so a few binaries, directories and items in PATH
may not be removed before the Makefile runs. Can't remember myself seeing the issue, so I'm glad you report it.
I think I have fixed it now by adding /opt/homebrew/bin
to the PATH
in the Makefile.
The output of the brew shellenv
command does not need to be added to .profile
, since /opt/homebrew/bin
is already in system/.path.
Happy to hear whether you think this is a proper fix and other questions you may have about this Makefile.
Installed my forked version on a fresh mac yesterday as well and ran into the same issue, it included your changes:
HOMEBREW_PREFIX := $(shell bin/is-supported bin/is-arm64 /opt/homebrew /usr/local)
PATH := $(HOMEBREW_PREFIX)/bin:$(DOTFILES_DIR)/bin:$(PATH)
Still failed with the same error as Jimmy, was also resolved by running the brew commands he mentioned.
Also hi 👋 , been a while. Thanks for the great scripts to build off of.
Hi & thanks Jordan! Just pushed eec8d4085f35da20b02c9a3c15701c8c216a2522, hopefully this helps. I noticed my previous "fix" also introduced bugs, as some paths were incorrectly removed (as they did not execute a binary, but were arguments to grep
and chsh
).
Just wanted to flag that this comes up on my new M2 MacBook Air running Ventura. Manually adding brew to path resolves, but I think maybe the conditional might be off? I see both /opt/homebrew/bin/bash
and /private/etc/shells;
exist, so I think that branch doesn't get hit?
Running the interior of the conditional yields that "append" is not a command
What solved it for me was:
- change shell to Bash (since macOS defaults to ZSH now)
- run
/opt/homebrew/bin/brew shellenv
- Paste back and execute all of the outputs (their exports).
- re-run make