sb2nov / mac-setup

Installing Development environment on macOS
https://sourabhbajaj.com/mac-setup/
Other
7.15k stars 1.02k forks source link

Macs with zsh: homebrew (and others ) now suggest setting path in ~/.zprofile instead of ~/.zshrc #356

Open porteusconf opened 1 year ago

porteusconf commented 1 year ago

I'm Submitting a ...

[x] Bug report
[ ] Tool/language/etc documentation request

Bug Location

https://github.com/sb2nov/mac-setup/tree/main/Homebrew#setting-up-your-path

Tool/Language/etc

``

Though setting path in .zshrc will work on macs, .zprofile may be better choice. Just avoid .zshenv always! As detailed at "Setting $PATH for zsh on macOS.md where they say ...

Using zsh, on macOS, avoid ~/.zshenv and choose ~/.zshrc or ~/.zprofile instead. In fact, better to replace ~/.zshenv with ~/.zprofile so that both Linux and macOS will use the same files with the very same config.

The gist also explains why this suggestion to mess with /etc/paths is not a good idea (as apple updates would likely overwrite anyways):

insert /usr/local/bin before the first line of /etc/paths to change the global default paths order, for all users and all major shells. <== bad idea. Not sure what right way is to change global path for all users on macos with zsh ;-)

And upon finish of homebrew install script, it suggests using .zprofile as follows for M1 macs:

echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> $HOME/.zprofile

This command to append output of brew shellenv to ~/.zprofile should only be run once.

For intel or rosetta2 users, it would be as below, which appends to to ~/.zprofile all the export lines shown.

echo 'eval $(/usr/local/bin/brew shellenv)' >> $HOME/.zprofile`
/usr/local/bin/brew shellenv
export HOMEBREW_PREFIX="/usr/local";
export HOMEBREW_CELLAR="/usr/local/Cellar";
export HOMEBREW_REPOSITORY="/usr/local/Homebrew";
export PATH="/usr/local/bin:/usr/local/sbin${PATH+:$PATH}";
export MANPATH="/usr/local/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/usr/local/share/info:${INFOPATH:-}";

Other Information

Nice work btw... if I find time I'll do a PR.

borgesnotes commented 1 year ago

Hey @porteusconf I fixed this kind of issue in a similar project: Mac-Setup guide. Check it out, maybe it will be useful too 😉