You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Still cant get zsh to work :-(

@vikingOSX answered some of my question earlier but I still cant get the command line to work properly.


I re-installed home brew in the hopes of re-installing git. I used this command from the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"


IT worked and installed brew. Yet when I attempt to run:

brew install git

I got:

zsh: command not found: brew


Any tips?


Many thanks

MacBook Pro 14″, macOS 13.0

Posted on Nov 28, 2022 3:01 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 28, 2022 3:30 PM

On M1 Macs, home brew expects to install packages in the /opt/homebrew directory tree, and on Intel Macs, it still uses the /usr/local directory tree. The ownership of either architecture installation should be yourname:admin.


You need to place /opt/homebrew/bin in your PATH statement in the ~/.zshrc so it knows where to find /opt/homebrew/bin/brew.


export PATH=".:/opt/homebrew/bin:/usr/local/bin:$PATH"


and once you save the ~/.zshrc file, you can issue the following commands:


source ~/.zshrc
brew update
brew upgrade
brew info git
brew install git


and a handy Zsh alias that you put in ~/.zshrc:


alias brew_deps='brew deps --tree --installed "$@"'


so that when you issue:


brew_deps git


you will see:




6 replies
Question marked as Top-ranking reply

Nov 28, 2022 3:30 PM in response to nuhuxi

On M1 Macs, home brew expects to install packages in the /opt/homebrew directory tree, and on Intel Macs, it still uses the /usr/local directory tree. The ownership of either architecture installation should be yourname:admin.


You need to place /opt/homebrew/bin in your PATH statement in the ~/.zshrc so it knows where to find /opt/homebrew/bin/brew.


export PATH=".:/opt/homebrew/bin:/usr/local/bin:$PATH"


and once you save the ~/.zshrc file, you can issue the following commands:


source ~/.zshrc
brew update
brew upgrade
brew info git
brew install git


and a handy Zsh alias that you put in ~/.zshrc:


alias brew_deps='brew deps --tree --installed "$@"'


so that when you issue:


brew_deps git


you will see:




Nov 28, 2022 4:06 PM in response to VikingOSX

Hmmmm I do this in terminal:

cd ~

LS -a


I see .zsh_history and .zsh_sessions but I dont see .zshrc. Is it possibly somewhere else?

I do a search on the entire mac and it doesnt show up.



OK - I dont think I understand what you are saying...


I have a file in ~ called '.zshrc'

that file contains just one line:

export PATH=".:/opt/homebrew/bin:/usr/local/bin:$PATH"


yet when I say 'source ~/.zshrc' it tells me

'zsh: no such user or named directory: .'

when I try 'source ~zshrc' (which makes sense to mebecause that file is in ~) it tells me:

'zsh: no such user or named directory: zshrc'

and

if I simply say:

zsh -v

I get an entire screen of output. I would assume that means that it can find zsh - yet it doesnt like the source command....


Nov 29, 2022 10:02 AM in response to nuhuxi

You are welcome. That alias command just shows you what the package dependency tree looks like. It doesn't perform an install. Useful info before you install a package…


Once you have that alias setup in your ~/.zshrc file, and source it, then you can enter the alias command as I showed it above.


I update or upgrade my operating system and nothing really changes other than perhaps the version of the Zsh shell or the version of homebrew that gets installed. No functionality changes.

Still cant get zsh to work :-(

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.