Why I do I see these lines in Terminal and how can I remove them?

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. Any tip.

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


Solution 1:

Each 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.

  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, 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 to back any file up or long term storage. It is very temporary.

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 or just not work.

Good luck in this “choose your own adventure” situation - there’s no wrong choice, and welcome to the team that wraps their brain around the wonderful world of shell programming using the unix idiom of computing.