3
Last login: Fri Mar 26 00:39:29 on console
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";

This started to appear at the start of the terminal when I installed homebrew and don't know how to remove it. I use zsh

PS: I don't know what I'm doing, so I will really appreciate a detailed response

bmike
  • 235,889
Zaro
  • 31
  • 3
    Which shell are you using? If you don't know, run echo $0 and tell us the result. – nohillside Mar 26 '21 at 11:41
  • 1
    You ask the best questions @nohillside - I’ll put the “here’s the path to learning” and a place to start type answer up. If we get an edit, a much shorter and precise exact answer is likely as well for Ahmed. – bmike Mar 26 '21 at 12:06
  • @nohillside i ran echo $0 and zsh poped up. – Zaro Apr 03 '21 at 07:42
  • Configure your terminal so that it starts a new shell with -x turned on. You will probably get plenty of output, but you will quickly see which command causes those lines to be printed. Alternatively, you could also try a simple zsh -xl in your current shell. Chances are that the problem will be reproducible, and you don't have to fiddle with your Terminal configuration. – user1934428 Jun 15 '22 at 13:29

2 Answers2

4

I got the same issue, It took me long enough to understand that it is simple to resolve.

During the installation of brew, we are supposed to execute this comand

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

I still remember I executed this command more than once, because of which the path is stored multiple times in .zprofile file.

enter image description here

When I deleted the first and second line using vim editor vim .zprofile

I was able to get rid of those annoying pop up messages.

1

Each default shell (the program that runs inside the terminal application) has two startup files.

If you look at the steps you performed when you set up homebrew, it asked you to modify those startup files. There is a syntax error or unintended side effect of the directions you followed to customize the files to prepare the homebrew environment. Look for lines containing eval or shellenv specifically.

  1. Take some time and change each line looks like it matches those strings - or systematically delete lines you think you understand what they do from your startup file and then test. Make one change, save the file, test. This is the path of learning your way out of this mess. This also could break your shell - so all manner of breakage can happen with an error in your startup scripts (or worse a loop).
  2. Throw away the startup files - go slower or with someone as you edit the shell startup files using brew doctor as guidance. This is safer if you don’t really know what you’re doing editing the files.

This “situation” happens to about 95% of the people learning how to set up a shell, so you might choose to pair up with someone that can work with you and show you the ropes or find a guided intro that explains how to debug your shell startup files. Eventually everyone breaks their environment with copypasta - even if the instructions were not malicious.

To clear the deck, if you know your backup of this Mac is current, just move the files to /tmp (kind of a junk drawer for shell files) and the log out (Apple Menu - log out of your entire graphical session) log in and try setting up your “dot files” again, slowly and making one line change at a time.

mv ~/.bashrc ~/.bash_profile ~/.zprofile ~/.zshrc  /tmp

Files in /tmp clear at boot so it’s not a good place for long term storage. It is very temporary and not a backup.

What that command does is move both bash and zsh startup files out of the way. I chose those two since they are the default shells covering recent macOS releases. If you chose a different shell or had setup already done, this will undo those settings.

Good luck in this “choose your own adventure” situation - there’s no wrong choice (although not backing up is a radical choice for some), and welcome to the team that wraps their brain around the wonderful world of shell programming using the unix idiom of computing.

bmike
  • 235,889