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

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

Open
porteusconf opened this issue Sep 28, 2022 · 1 comment

Comments

@porteusconf
Copy link

porteusconf commented Sep 28, 2022

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.

@monsieurborges
Copy link

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

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

No branches or pull requests

2 participants