brew update (homebrew) take a lot of time to run - macos

I am a new mac user,
and I just installed HomeBrew to set up my computer for business use,
but every time I run a brew command,
brew update
is started automatically and takes a lot of time,
I have time to do what I want before it works!
please be indulgent with me and teach me a way to solve my problem
I want to clarify that I do not have a network problem because everything works correctly on this side.
Thank you.

Add the following config into your shell init files. (.bash_profile for Bash, .zshrc for ZSH)
export HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_NO_AUTO_UPDATE: If set, Homebrew will not auto-update before running brew install, brew upgrade or brew tap.

Related

How to start over with Homebrew?

I recently replaced my Intel Macbook with an M2 Mac, using my Time Machine backup to initialize the hard drive. That, of course, dutifully copied all the Intel code.
I had brewed onto the old system. Today running brew upgrade gives me:
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
So of course I ran brew bundle dump and that didn't give me any more direction. I'm ready to wipe the entire slate clean with something like rm -rf xxx and start over, but I feel like I should be choosy about xxx.
FWIW, brew --version returns:
Homebrew 3.6.5-10-gbde685a
Homebrew/homebrew-core (git revision d6fa8906828; last commit 2022-10-11
Homebrew/homebrew-cask (git revision 576798b72f; last commit 2022-10-12)
Any real help would be welcome (except "switch to macports").
It turns out that just running "brew bundle dump" is only the first step. Follow that wit "brew bundle install --file Brewfile", as explained very clearly in earthly.dev/blog/homebrew-on-m1
Don't rush to follow my advice, or accept my answer. Someone else may give you something better if you are patient...
You should be able to get a list of installed packages in the current setup then it'll be easier to install the same packages in the new one. Try this and see if it looks correct:
brew ls > ~/oldbrewpackages.txt
You need to find where your current casks and stuff are installed. Like this:
brew config
and look for HOMEBREW_PREFIX. Snuffle around in there and see if it looks like where all your packages are.
Next, I would look around for anything to do with homebrew in my login profiles, comment it out by putting a hash (#) at the start of the line, save the file and check you can still start a new Terminal without errors:
grep -i homebrew -/.*
Now, rather than removing all your homebrew stuff under HOMEBREW_PREFIX, I would try renaming it. You may need to turn off "System Integrity Protection" first.
Then if your homebrew stuff is under /opt/homebrew, you could do:
sudo mv /opt/homebrew /opt/homebrew.unused
Then you'll want to reboot.
Now you should be able to install a new homebrew without it detecting the old one... hopefully.
To install your previous packages in your new homebrew, you want:
brew install $(cat -/oldbrewpackages.txt)
If everything looks good and works well, make a backup and then type the command to delete your old stuff, and read it very carefully 3x before hitting Enter
sudo rm -rf /opt/homebrew.unused

How to fix Mac terminal being incredibly slow after brew install tmux

I've installed tmux using brew ( arch -x86_64 brew install tmux ) on M1 Mac and since then my terminal is super slow. on lunch, after running commands and it's just incredibly slow.
I tried deleting the package using
brew uninstall pkg
it didn't work. I tried using the following commands as well.
brew remove pkg
brew rmtree tmux
I get "Error: tmux is not currently installed" since I've already uninstalled it..
and when using
sudo find / -name "*tmux*"
I still get many files including tmux.
GIFs showing the situation
any ideas/help on how to solve this?
Ok I have fixed it.
although I didn't know exactly what was the problem but it was something related to oh-my-zsh and to be more specific it was with the current oh-my-zsh theme powerlevel9k after installing tmux.
here is the steps I toke: I tried to change my shell to bin/bash it worked great. Tried a couple more shells and all worked great except zsh. then I tried to change the .oh-my-zsh directory name just for testing purposes and opened zsh, it worked great but of course without oh-my-zsh.
so I went to .zshrc and commented this line.
#ZSH_THEME="powerlevel9k/powerlevel9k"
obviously installing tmux messed things up so I'll need to reinstall the theme or oh-my-zsh all over again.

MongoDB installed via Homebrew not working

I installed MongoDB via Homebrew (following http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/) but it's not working.
Typing mongod at shell prompt gives me:
-bash: mongod: command not found
Not sure if I need to add something for Homebrew to my PATH env var?
I can see Mongo is installed under /usr/local/Cellar/mongodb – but am assuming I don't need to add everything I install via homebrew to the path? Also, assuming I can run mongod from any directory or am I actually meant to be in install directory?
When I run brew doctor I get:
Warning: You have unlinked kegs in your Cellar
Followed by a list of 3 items which includes MongoDB – but I'm not sure how I'm meant to link them?
Works perfectly
brew update
brew tap mongodb/brew
brew install mongodb-community#4.2
For latest version, check https://docs.mongodb.com/manual/release-notes/
You're getting this error because your 'brew' install failed to create the correct symlinks in /usr/local/bin. As a result, the shell can't find the mongo executables in your $PATH. You can fix this using the following steps:
Check the permissions on /usr/local/bin and make sure that you own that directory and have write permissions on it
$ ls -ld /usr/local/bin
Once you've fixed that, run 'brew link' to fix the symlinks
$ brew link mongodb
If you are on mongodb-community#4.0. You can try to reinstall with brew reinstall mongodb-community#4.0.
Then I get the following hint:
==> Caveats
mongodb-community#4.0 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mongodb-community#4.0 first in your PATH run:
echo 'export PATH="/usr/local/opt/mongodb-community#4.0/bin:$PATH"' >> ~/.bash_profile
So you can just copy the echo command and restart your shell!
Copied from a different channel running these commands in the terminal updated the installation/configuration issues as described in OP
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
I faced the same problem and this solution seemed to work for me. I had previously uninstalled mongodb and reinstalled it through homebrew which gave me a bunch of problems. This solution seemed to work just fine.
brew uninstall --force mongodb
brew cleanup -s mongodb
brew cleanup --prune-prefix
brew install mongodb
It works from the directory since the sh searches the ENV path and then the cwd for a program named mongod. I have been looking around a little and it seems that the default install of MongoDB (I am not a Mac user) does not install a rc or init script for which sh to understand it's running behaviour as stated here:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/#using-mongodb-from-homebrew-and-macports
The packages installed with Homebrew and MacPorts contain no control
scripts or interaction with the system’s process manager.
If you have configured Homebrew and MacPorts correctly, including
setting your PATH, the MongoDB applications and utilities will be
accessible from the system shell. Start the mongod process in a
terminal (for testing or development) or using a process management
tool.
So you must actually define (as you said) MongoDBs path, here is an example: https://snipt.net/sido/installing-mongodb-on-os-x/
Edit: the example is not mine. I just stole it from it's user: https://snipt.net/sido/

Run Octave within the same Terminal session

I set an alias in my .bash_profile for Octave
alias octave="open /Applications/Octave.app"
It opens in a new Terminal window. How do I run Octave within the same Terminal session like Python does?
Found it:
alias octave = "/Application/Octave.app/Contents/Resources/bin/octave"
Your mileage may vary, but I just installed Octave via homebrew
$ brew install homebrew
...and it actually worked. It failed once, and I had to manually brew install gfortran but then everything came together nicely.
I had tried this a year ago and it was very painful and I ended up using the bundled .app version like you (and made an alias exactly like the one you came up with), but now installing from source seems to have worked great. Plus, it gives you more options for plotting besides gnuplot.

How do I modify a Homebrew formula?

I installed ImageMagick via Homebrew.
However, due to a bug I have with my current configuration, I need to adjust the compile flags for the formula and reinstall it.
How can I accomplish this?
Remove the existing version.
$ brew rm imagemagick
Edit the formula.
$ brew edit imagemagick
This will bring it up in an editor; make sure your $EDITOR variable is set to your preference (for me: TextMate)
Change it, save it, try re-installing it.
Because most installs use pouring/bottles to install a precompiled binary, you will likely see no change unless you "build from source":
$ brew reinstall --build-from-source [...]
You can use --formula /path/to/imagemagick.rb as an additional argument to the above command to ensure brew is installing the formula that was edited.
If you're comfortable with git, you may also want to make a branch first, and do your edits in a branch to guard against data loss.
The accepted answer was the first step, but more was needed for my formula edit to work in February 2023.
If you edit formula foo, but your change is ignored by brew reinstall --build-from-source foo then, add export HOMEBREW_NO_INSTALL_FROM_API=1 to your shell config. It makes Homebrew actually use your revised formula.
Details: Homebrew FAQ: Edit Formula
Also, if you want your revised formula to persist, then run brew pin foo
Details: Homebrew FAQ: Prevent Formula Update/Upgrade

Resources