Terminal prints all brew commands whenever I open terminal

I am using M1 chip MacBook Pro, os is Ventura 13.0.1. I recently installed brew but since then terminal behaves weirdly. It prints brew commands whenever I open terminal or new terminal tab. I need help to fix this issue. It almost takes 6-8 seconds to print all this and be ready to execute.


For ex.

Example usage:

 brew search TEXT|/REGEX/

 brew info [FORMULA|CASK...]

 brew install FORMULA|CASK...

 brew update

 brew upgrade [FORMULA|CASK...]

 brew uninstall FORMULA|CASK...

 brew list [FORMULA|CASK...]

.

.

.

.

Further help:

 brew commands

 brew help [COMMAND]

 man brew

 https://docs.brew.sh

source ~/.bash_profile

MacBook Pro

Posted on Feb 16, 2023 10:02 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 16, 2023 11:59 AM

dhruvalshah wrote:

Yes, I think there is some issue with using zsh shell. Because I switched to bash and it didn't print anything.

I did echo $SHELL and it showed /bin/zsh. I didn't understand what exactly I need to do in this case.


The following command shows which shell you are using:

echo $SHELL

You are using zsh.


Exactly what you need to do next is to review and debug the contents of your login-related scripts.


This will entail learning more about the command line and the shell.


Here are the zsh-related scripts:

https://apple.stackexchange.com/questions/388622/zsh-zprofile-zshrc-zlogin-what-goes-where#388623


Review each of those for a brew-related command or script.


Your existing login scripts have calls to other scripts (whether added by you or others or other installed apps or tools), and you need to review each of those other scripts, too.


You also have two package installation managers installed, which can make for a more complex command-line environment; both SDKMAN! and Homebrew. SDKMAN! is not one I’ve used. Homebrew, yes, I have and do use that. (I see a total of three references to SDKMAN! around here in ASC too, and two of them are from you here.)


There are books and online resources on learning zsh, likely also videos and classes. Homebrew has some doc, but the issue here looks to be with a brew command, which should be fairly visible in whatever shell script is being run, and running awry.


Similar questions

15 replies
Question marked as Top-ranking reply

Feb 16, 2023 11:59 AM in response to dhruvalshah

dhruvalshah wrote:

Yes, I think there is some issue with using zsh shell. Because I switched to bash and it didn't print anything.

I did echo $SHELL and it showed /bin/zsh. I didn't understand what exactly I need to do in this case.


The following command shows which shell you are using:

echo $SHELL

You are using zsh.


Exactly what you need to do next is to review and debug the contents of your login-related scripts.


This will entail learning more about the command line and the shell.


Here are the zsh-related scripts:

https://apple.stackexchange.com/questions/388622/zsh-zprofile-zshrc-zlogin-what-goes-where#388623


Review each of those for a brew-related command or script.


Your existing login scripts have calls to other scripts (whether added by you or others or other installed apps or tools), and you need to review each of those other scripts, too.


You also have two package installation managers installed, which can make for a more complex command-line environment; both SDKMAN! and Homebrew. SDKMAN! is not one I’ve used. Homebrew, yes, I have and do use that. (I see a total of three references to SDKMAN! around here in ASC too, and two of them are from you here.)


There are books and online resources on learning zsh, likely also videos and classes. Homebrew has some doc, but the issue here looks to be with a brew command, which should be fairly visible in whatever shell script is being run, and running awry.


Feb 16, 2023 11:16 AM in response to dhruvalshah

I have been running Homebrew for years and it does not insert any command into any SHELL dot file. Doesn't even modify the PATH variable, which you will need to do on your own if you want to access and /opt/homebrew/bin commands on an Apple Silicon Mac.


Launch the Terminal. Enter the following command so there is no doubt about the SHELL you are using:


echo $SHELL


If that says /bin/zsh, then you should create and enter your SHELL PATH and other content in the ~/.zshrc file. If it is /bin/bash, then use ~/.bash_profile.


In either SHELL case, you should not have any function, alias, or command in your dot file that runs brew.


We cannot help with any Google SDK or related commands, or your not following directions in your ~/.zshrc file.

Feb 16, 2023 10:55 AM in response to dhruvalshah

Is suspect that the two lines at the end may be causing this.


To make sure, you could edit this file and prefix those final lines (the ones starting with eval) with the comment character #:


# eval "$(/opt/homebrew/bin/brew shellenv)"


# eval "$(/opt/homebrew/bin/brew shellenv)"




then save the file. Quit Terminal and start again. Does it still behave the same way?

Feb 16, 2023 10:16 AM in response to Luis Sequeira1

I did ~ % cat ~/.bash_profile and got following response


#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!

export SDKMAN_DIR="$HOME/.sdkman"

[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

export PATH="$PATH:/usr/local/git/bin:/usr/local/bin:"

# The next line updates PATH for the Google Cloud SDK.

if [ -f '/Users/dhruvalshah/Downloads/google-cloud-sdk/path.bash.inc' ]; then . '/Users/dhruvalshah/Downloads/google-cloud-sdk/path.bash.inc'; fi


# The next line enables shell command completion for gcloud.

if [ -f '/Users/dhruvalshah/Downloads/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/dhruvalshah/Downloads/google-cloud-sdk/completion.bash.inc'; fi

# Set PATH, MANPATH, etc., for Homebrew.

eval "$(/opt/homebrew/bin/brew shellenv)"


eval "$(/opt/homebrew/bin/brew shellenv)"

Feb 16, 2023 11:10 AM in response to Luis Sequeira1

% cat ~/.zshrc


#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!

export SDKMAN_DIR="$HOME/.sdkman"

[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"


export gcloud="/Users/dhruvalshah/Downloads/google-cloud-sdk/bin"

# The next line updates PATH for the Google Cloud SDK.

if [ -f '/Users/dhruvalshah/Downloads/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/dhruvalshah/Downloads/google-cloud-sdk/path.zsh.inc'; fi


# The next line enables shell command completion for gcloud.

if [ -f '/Users/dhruvalshah/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/dhruvalshah/Downloads/google-cloud-sdk/completion.zsh.inc'; fi

# echo "source ~/.bash_profile"

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal prints all brew commands whenever I open terminal

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