How to run the Homebrew installer under Rosetta 2 on M1 Macbook - macos

I'm on the M1 MacBook.
This is the error when I try to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Homebrew is not (yet) supported on ARM processors!
Rerun the Homebrew installer under Rosetta 2.
If you really know what you are doing and are prepared for a very broken experience you can use another installation option for installing on ARM:
https://docs.brew.sh/Installation
So how do I "Rerun the Homebrew installer under Rosetta 2."?

Got an answer from a developer in the Homebrew github https://github.com/Homebrew/brew/issues/9173
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Use this to install packages:
arch -x86_64 brew install <package>
If you have not yet installed Rosetta 2 to emulate Intel CPUs on ARM Macs, you will get the error arch: posix_spawnp: /bin/bash: Bad CPU type in executable. Prompt a Rosetta 2 installation with:
softwareupdate --install-rosetta

I have two instances of brew installed, the Intel version that runs using Rosetta2 and which installs to /usr/local/bin and the Arm version that runs natively and installs to /opt/homebrew/bin. Now it is all working, I do not have to start iTerm using Rosetta.
I have these aliases to reach the two versions.
ibrew='arch -x86_64 /usr/local/bin/brew'
mbrew='arch -arm64e /opt/homebrew/bin/brew'
I have the native version in my path first:
path=( /opt/homebrew/bin /opt/homebrew/opt /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin )
Now I can try mbrew search and mbrew install. If they work, I am good to go with a native program. For example:
mbrew install ag
If brew fails I try building from source, with verbose output, e.g.
mbrew install -sv rust
Be warned, this takes a while and may still fail.
If it still fails, (and mbrew install -sv go results in a segmentation fault for me) I have two choices. Use ibrew search and ibrew install to get the Intel build instead, or examine the verbose output and look for problem dependencies. In some cases an install -s on the dependencies is enough to get the native brew to work.
I must stress that native brew always prints this warning
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
So proceed at your own discretion.
For completeness, and assuming you have iTerm2, Rosetta2 and the Xcode command line tools installed, I did this to install brew under Rosetta (with credit to all those who have posted on this page before me):
Copy the installed iTerm2.app application to iRosetta2.app
Press command+I to Get Info for iRosetta.app, click Open Using Rosetta2
Run iRosetta2 and use this command from https://brew.sh
Like so
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
alias ibrew='arch -x86_64 /usr/local/bin/brew' # put this in ~/.zshrc
And I did this to install native brew, taken from other contributors to Stack Overflow and the Homebrew alternative installation site, using iTerm2 without Open Using Rosetta2
mkdir ~/homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
sudo mv ~/sudo mv homebrew /opt
mbrew='arch -arm64e /opt/homebrew/bin/brew' # for .zshrc
export PATH="/opt/homebrew/bin:/opt/homebrew/opt:$PATH" # also for .zshrc
Edit
Time has passed and I have changed the architecture to arm64e following Fernando García Redondo observation. Now the warning about Arm architecture not supported has gone and Rust and Go install without problems and without compiling from source. I assume the good people at Homebrew have been working hard over Christmas. Thanks!
Edit Feb 21
The Homebrew team have announced that they support Apple silicon. So I wondered if I could delete my aliases and just use brew to install for Apple silicon. The short answer is no! if you run brew from /usr/local without the arch -x86_64, it complains that /usr/local is reserved as the Intel default prefix and using /opt/homebrew is required. So I will retain my two aliases and try mbrew first and only use ibrew if the native brew fails.

Another option is by going into your applications in Finder, select Terminal and press ⌘+I and check the "Open using Rosetta" option.
Sorry if the formatting is off, first time posting a solution.

The easiest way to run Homebrew is with Rosetta 2.
1. Duplicate Your Favourite Terminal for Rosetta
Find your favourite terminal, right-click to duplicate it, and rename it for easier identification. In this example, I'm using the default Terminal app on Big Sur 11.2.1.
Right-click the Terminal Rosetta and go to Get Info to check the Open using Rosetta option.
2. Install Homebrew
Open the rosetta terminal and run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Running this command will ask you for the password, and then it will provide you with the information of what all it will install and which new directories it will create.
3. Using Homebrew
Once HomeBrew is installed, you can start using it to install your required packages into the M1 Mac.
Run the following command to get brew help:
brew help
To install a package, you can run the following command:
brew install packagename
That’s all about installing and getting started with Homebrew on Apple M1 Macs.
EDIT: Thanks all! Upvote to help other devs! Homebrew 3.0.0 now officially supports Apple Silicon (https://brew.sh/2021/02/05/homebrew-3.0.0/)

After I installed Rosetta, I added an alias so I can use brew install <package> as I would normally.
alias brew='arch -x86_64 brew'
I agree with everyone else in that you need to add the arch -x86_64 in front of the original command so thought to include that alias to help anyone finding this thread in the future

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" worked on my new M1 Mac

Do below
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias brew='arch -x86_64 brew'
brew install azure-cli
now try az login. you are good to go

You can change the setting of Terminal to launch it using Rosetta.
Go to your Application/Utilities folder, right click on the Terminal App and check the tick box 'Open using Rosetta'
But to be honest, I have Homebrew installed without Rosetta. Just removed the x86 version yesterday and installed a fresh version without Rosetta.

Related

Can anybody tell how to install gcc in m1 MacBook Air?

there
Actually I've recently buy an MacBook Air, And I try to install gcc on my MacBook and I've already installed VS Code on it and after I installed home brew then when I typed brew install gcc...
Then it throw an error i.e. :
zsh: command not found: Brew
Can you help me ?
So your trying to install something that's based on a bash script? If so go into SysPref>User's, unlock, then right click on the Admin or Login goto advanced options and login shell. Or there's this chsh -s /bin/bash. That came from here
So actually you are getting the error "zsh: command not found: Brew"
So it is not the error of gcc it means brew is not installed on your system.
First you have to install that using this cmd:
[/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After that you can run brew install gcc which will work fine then!

Install Zathura on macOS 10.10.2

I am trying to install Zathura on a Mac OS X 10.10.2. I have downloaded Zathura 0.3.2 and tried to run make but it requires girara. Girara requires gtk 3.2 but brew install gtk+3 only installs 3.14.
Does anyone know a set of procedures to install Zathura?
Since this question and answer is about 6 years old, here's a current method for Big Sur as of writing (expanding on my edit of this answer on Ask Different).
I originally tried to compile it using the suggested method in the documentation which is this MacPorts port. Although it compiles, it gives the error Gtk-WARNING **: cannot open display when running. There are fixes for other ports of programs with the same error but instead, I found a Homebrew tap which installs it without issues.
To install:
brew tap zegervdv/zathura
brew install zathura
brew install zathura-pdf-mupdf
mkdir -p $(brew --prefix zathura)/lib/zathura
ln -s $(brew --prefix zathura-pdf-mupdf)/libpdf-mupdf.dylib $(brew --prefix zathura)/lib/zathura/libpdf-mupdf.dylib
There is work to integrate the program better into macOS but it's still in development - see here.
I solved the problem by adding the adding the following to my $PKG_CONFIG_PATH:
export $PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/Cellar/zlib/1.2.8/lib/pkgconfig:/usr/local/Library/ENV/pkgconfig/10.10
I could then make and make install without any problems.

how to install libX11 on OSx 10.9?

I am trying to install ROOT (cern.root.ch). When I run ./configure , I get a message that libX11 is missing and must be installed.
I did some research and found that I need to install
) XQuartz (I already have the latest version.)
) Command line tools in Xcode.
I tried installing Command Line Tools from apple's developer website. The installation goes through smoothly but how do I know whether it has been installed? I still get libX11 missing error with root's configure command.
I also tried xcode-select --install and it once went through smoothly and then later again gives error saying this package is no longer maintained - or something of that sort.
I understand I may have multiple installations... But I am still facing the problem of not having libX11 and not being able to install ROOT.
Thanks,
Hershal.
This link and the one referenced in it suggests you use homebrew (brew) to install it
$ ruby <(curl -fsS https://raw.github.com/mxcl/homebrew/go)
$ brew doctor
Remember to add the Homebrew directory to your PATH by adding the directory (found with brew --prefix) to your .bashrc, .zshrc or whatever shell file you’re using (.bashrc is the OS X default). We’ll also add the XQuartz binaries to the PATH in case anything needs them in the future.
export PATH=/usr/local/bin:/opt/X11/bin:$PATH
Start a new Terminal session to pick up the changes.
Now that Homebrew is installed, we can use it to install the required dependencies. Each may take some time as Homebrew generally compiles from source.
$ brew install gfortran # Fortran compiler
$ brew install python # Python interpreter
$ brew install pcre # Regular Expressions library
$ brew install fftw # Fast Fourier Transforms
$ brew install cmake # Cross-platform make
install root
$ brew tap homebrew/science
$ brew install --with-cocoa root
You don't say whether you have installed XCode as well as the commandline tools but I think you will need it

How to install MIT Scheme on Mac?

I want to install MIT Scheme on my Mac, I have downloaded the MacOS X binary(x86-64).
However, I could not make it work using Mac Terminal.
I have tried to follow these articles:
Installing MIT/GNU Scheme on Mac OS X Leopard
Installing MIT Scheme on Mac OS X
but it seems out of date and does not work.
So, I'm looking for a simple method which allows me to write Scheme code using Mac Terminal.
I have struggled for hours to try to install it.
UPDATED FOR EL CAPITAN:
The best way that I've found was from here:
Download either the 32-bit or 64-bit dmg file for Scheme.
Double click the .dmg file, and you'll get this window, in which you should drag the "MIT/GNU Scheme" file into the Applications folder.
For the 32-bit version, run this command:
sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-i386
Then enter your administrator password, and run this command:
sudo ln -s /usr/local/lib/mit-scheme-i386/mit-scheme /usr/local/bin/scheme
For the 64-bit version, first run this command:
sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64
Then enter your administrator password and run this command:
sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/local/bin/scheme
And that's it! Now you should be able to use MIT Scheme in your terminal by typing "scheme" into the command line:
Homebrew makes it easy for you. On Terminal, type:
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) ; brew install mit-scheme
Done!
Edit
The install script has been moved:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ; brew install mit-scheme
For Yosemite 10.10.3:
After installing X11.app and homebrew,
$ brew tap homebrew/x11
$ brew install mit-scheme
I found it easier when a maintained package manager such as homebrew covers all the dependency and build stuff.
Edit: simply
$ brew install mit-scheme
would do. X11 is now optional instead of dependence. There is still an --with-x11 option which requires whole Xcode.
You can install scheme using homebrew using the following command
brew install mit-scheme
If you have the latest version of Mac system, El Capitan 10.11.2, You might need to do something different than above.
The first command will be same.
For the 64-bit version, first run this command:
sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64
Then enter your administrator password and run this command:
sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/local/bin/scheme
Note: The difference is you need to put local between /usr/ and /bin/
Type scheme in the terminal to see if it works. If you get the following screenshot, that means you succeed it.
Success Result
You definitely need to put local there.
The reason is this, Apple improved OS security in OSX 10.10 (rootless), and changes to the general system-wide binaries (such as /usr/bin) is not permitted.
If you are having trouble with the accepted answer from #virgil-ming, try this:
$ brew install Caskroom/cask/xquartz
$ brew install mit-scheme
Same idea, of course, but this got me up and running when brew tap homebrew/x11 responded with multiple conflicts.
As always, remember to brew update then try again when you are having problems, a la Homebrew's troubleshooting guide.
If you are using docker, and I recommend you do:
docker run -it inikolaev/alpine-scheme
will drop you right into a scheme REPL.
UPDATE FOR MAC OS HIGH SIERRA:
Worked for me just by executing (if you are using Homebrew):
brew install mit-scheme
If you are using MacPorts, the command is similar to what others have posted for homebrew -
sudo port install mit-scheme
That set me up pretty well on OS X 10.8.5
I came across a problem that the 10.x versions of the MIT/GNU Scheme do not support Mac OS X 10.11 El Capitan. In fact, it requires Mac OS X 10.13 or higher.
The topmost version supporting older Mac OS X versions is MIT/GNU Scheme 9.2.

Installing meld on OS X

After I got MacPorts installed and did a 'sudo port -v selfupdate', I try to install meld.
The installation just starts to Fetching all kinds of stuff
gnome-comoon
perl5.8
perl5
pkgconfig
.....
this goes on and on.
Is that normal?
You may want to install it via HomeBrew (already mentioned before):
brew install homebrew/gui/meld
Though you may face stability issues (as I did). So I'd rather recommend to use "Meld for OSX":
Go to https://yousseb.github.io/meld/
Download DMG file you prefer (e.g. "Download latest DMG" https://github.com/yousseb/meld/releases/download/osx-6/meldmerge.dmg)
Install it to your Applications folder
We are basically done, but it is not accessible via command line.
Solution:
Write a small wrapper to run from Terminal:
echo -e '#!/bin/sh
params="$#"
open -W -a Meld --args $params' | sudo tee /usr/local/bin/meld
sudo chmod +x /usr/local/bin/meld
Try (you must use absolute paths though):
meld /home/a.txt /home/b.txt
Or just run Meld from menu.
meld is now available in homebrew. The formula can be found here.
See this answer by cmedeiros on SuperUser for more information on installing and getting it to work. This is much easier than using MacPorts.
Current command with updated formula to install meld with homebrew is:
brew install caskroom/cask/meld
Yes, it is normal to pull in dependencies but it shouldn't take too long. For comparison, installing Meld with Homebrew took about 15 minutes for me.
For reference, my installation of Meld on OS X Mavericks:
Install Xcode from the app store
Install XQuartz from package (Meld will complain if you don't have it)
command line: 'brew install meld'
If you are prompted to install the Xcode command line tools at some point, do so.
Hope this helps.
Unfortunately, the is very normal with MacPorts, and is the reason that people many have switched to homebrew http://github.com/mxcl/homebrew
However, I found this post because homebrew doesn't include Meld. Sigh.
Consider downloading macOS meld version dmg https://github.com/yousseb/meld/releases/
Brew now works brew install --cask meld.
See https://formulae.brew.sh/cask/meld#default
UPDATE Jul-23-2020
Just do :
brew install homebrew/gui/meld
using the updated brew link: brew install caskroom/cask/meld
even after this its not working when I install backup and restore tool by google. I guess its messing up with the python version.

Resources