How to install homebrew on mac M1 chip problem - homebrew

Now, I successfully installed homebrew on my macbook
bue every time after I closed terminal and reopen terminal
I need to type -> export PATH=/opt/homebrew/bin:$PATH
and then type -> brew --version is OKAY
My question is, how can I fixed this problem into when every time I open terminal,
I can directly type brew --version can work?

Related

After homebrew installation and using it to install miniconda on Monterey MacOS, conda is not found.(Q1) How to resolve? (Q2) How to remove miniconda?

Using: MacOS Monterey v12.2, Apple M1 Pro chip.
After installation of homebrew and using it to install miniconda with this command 'brew install --cask miniconda' on the mac terminal, it states that conda is not found.
Yet, if i key the command 'brew list' on mac terminal, miniconda is seen in the casks.
(Q1) How to resolve the above i.e. make miniconda work via this homebrew download method? (Also, it seems like unlike in intel MacOS, miniconda is stored in this directory -> "opt/homebrew/Caskroom/miniconda/base" in M1 MacOS)
(Q2) Alternatively, i downloaded the miniconda installer (from https://docs.conda.io/en/latest/miniconda.html). This miniconda installer works and it seems to reside in a different path -> "/Users/xxxx/opt/miniconda3" (refer to Image 1). Concern that there might be conflict if there are two miniconda in my macOS. So then, how can i remove the miniconda which i downloaded earlier via homebrew? The command 'brew uninstall miniconda' or ''brew uninstall --cask miniconda' did not work? (refer to Image 2)
I kept running into these kinds of problems with python on my M1 Mac until I went completely to Rosetta on the command line wrt python. For that, I did the following:
Update Rosetta:
In a Terminal type:
softwareupdate --install-rosetta
In Finder, type ⇧⌘G and go to /Applications/Utilities. Then duplicate Terminal:
Rename the second Terminal to "Rosetta" (or whatever you like) and have it execute in Rosetta by checking "Open using Rosetta" in the "Get Info" dialogue:
Open a Rosetta Terminal and make sure it shows i386 when you issue the command arch:
In that terminal, install homebrew (per the homebrew homepage):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once homebrew has been installed, install miniconda using homebrew:
brew install --cask miniconda
Create a conda environment, for instance here a python 3.9 env named py39:
conda create -n py39 python=3.9
Activate the environment:
conda activate py39
From here on out, you have a fully functioning i386 Python system. This has resolved all problems that I had with Numpy, Pandas, Azure, etc. on my M1 Mac.

Bad CPU type in executable after migrating to new Macbook

I just got a new Macbook and did the migration from my old one. It looks like the homebrew executables have a bad CPU type and don't work. Things are a bit stuck right now and I'm not sure how to move forward.
Even my ls is mapped to lsd and I can't list files.
Do I have to manually uninstall brew and related executables by deletion and start over?
DISCLAIMER: I didn't test this myself.
If you don't want to alwasy use Rosetta2, you have to manually remove the Intel version of Homebrew, then install the M1 version.
You can save the list of your Intel installed package with:
brew list > myHomebrewPackages.txt
You will then have to reinstall them on the M1 version.
To remove the Intel version, download the uninstall script from the official Homebrew github repository. Make it executable with:
chmod +x uninstall.sh
and run it with:
./uninstall.sh --path=/usr/local
Then install the M1 version with:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The M1 version of Homebrew will be installed under /opt/homebrew.

homebrew with M1 macbook air error when starting terminals

I installed homebrew 3.0.0 on my M1 MBA.
However, every session including iterm2 terminal and tmux shows this error message:
/Users/jinrae/.zprofile:1: no such file or directory: opt/homebrew/bin/brew
In my case, it does not harm functionality at least in my usage pattern.
Anyhow, how can I get rid of this message?
I got this error because I installed brew on the Rosetta version of terminal to install packages, that are not yet M1 compatible.
To get rid of this message i opened my .zprofile with nano .zprofile.
The first line was
eval "$(/opt/homebrew/bin/brew shellenv)"
And i simply put a # before this line to comment it out and the message was gone.
To #sedavidw, /opt/homebrew/bin contains .keepme without contents:
/Users/jinrae/.zprofile:1: no such file or directory: opt/homebrew/bin/brew
➜ bin pwd
/opt/homebrew/bin
➜ bin la
total 0
-rw-r--r-- 1 jinrae admin 0B Feb 9 11:04 .keepme
EDIT: I read an article saying that homebrew is installed in /opt/homebrew/bin in M1 Mac whereas it is installed in /usr/local in Intel Mac. I'm trying to reinstall homebrew for M1 Mac now.
EDIT2: I solved the problem. It was due to for what homebrew is installed. As I heard, homebrew is installed in /usr/local for Intel Mac and /opt/homebrew/bin for M1 Mac.
I reinstalled homebrew with
/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa/raw/48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"
which is slightly different from that in the official site (at least to me).
Anyhow, newly installed homebrew is located in /opt/homebrew/bin and the problem has been solved.
If you are using an Intel Mac, as mentioned above, Homebrew gets installed on /usr/local. Therefore, modify your .zprofile file (located in users/<username>) to use the correct path. Here is content of .zprofile:
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
I have the M1 Mac and it was installed in /opt/homebrew/...
I opened /Users/~username~/.zprofile and it had two lines.
First line was:
eval "$opt/homebrew/bin/brew shellenv"
Second like was:
eval "$(/opt/homebrew/bin/brew shellenv)"
I just commented out the first line which doesn't actually have the </opt/> in the address. It's asking for a $opt, and then the address. So commenting out that line removed the location error and just read the correct line. So it doesn't show the error anymore when opening the terminal.
To Fix Type
nano .zprofile
then delete all of the stuff
then do ⌃X
then press return

Not able to install homebrew on my m1 macbook

I am trying to install homebrew on m1 MacBook but I am getting this error message every time when I try to run this command.
Please anyone help me to fix this.
How to install HomeBrew on new MacBook: macOS Big Sur
install HomeBrew from terminal Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After installation, we need to change path
Warning: /opt/homebrew/bin is not in your PATH.
==> Installation successful!
To change path, follow Next steps: - Add Homebrew to your PATH in /Users/username/.zprofile As mentioned in terminal:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/username/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
All done ready to use brew, check HomeBrew version:
brew --version
Output
Homebrew 3.1.5
Homebrew/homebrew-core (git revision 5741ae3fec; last commit 2021-05-08)
Ok, I managed to figure this out after being pointed in the right direction. Full details can be found here: https://github.com/Homebrew/homebrew-cask/issues/100633
In summary, my ISPs (Virgin Media) Web Safe Settings were on, and this resulted in some issue with connecting to github (ping GitHub.com via terminal and search the IP to see where its pointing to), so had to turn off the web settings, rebooted my router just in case and used a new terminal window to ping github.com again and noticed a change in the IP address. Tried reinstalling Homebrew again and it worked!!
in my case, i fix the problem open the terminal as rosseta.
finder - application - utility - terminal - right mouse button - 'bring the imformation (i'm not sure, i'm korean user)' - check the 'open with the rosseta' - and try install homebrew again ! !
(copy-paste Homebrew with the terminal)
and...
==> Installation successful!
But, you will get a warning " /opt/homebrew/bin is not in your PATH". Then, follow the Next steps guide showed in terminal to finish add Homebrew to your PATH.
To end, type "brew -v" to check installed brew version.

start brew cask apps from terminal

I installed signal using brew cask (brew cask install signal)
I would like to be able to start the GUI app from terminal by typing signal(e.g.: to run the GUI of emacs [installed using brew cask] I can type emacs)
Maybe there is a way to edit the cask file to create this link?
I understand that I can create an alias in my zsh config file, but I was wondering if that is the correct approach.
You can use open to open any app on macOS, it's not related to homebrew, but you can extend your integration as you see fit. Example: open -a signal.

Resources