How can I install Homebrew into /opt/?

Orest Tokovenko picture Orest Tokovenko · Nov 19, 2020 · Viewed 9.5k times · Source

I'm on the new M1 MacBook Pro. I'm trying to install gtk+3 (which has native apple silicon support) via Homebrew. First it told me

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

I tried to run the terminal via Rosetta 2, but gtk+3 needs ARM support to install, so that didn't work.

I tried to manually unzip the code line in docs.brew.sh in /opt/ but it told me I don't have permission. I tried to sudo it, but to no avail. Any help?

Edit 1: for full message:

brew install gtk+3  
Updating Homebrew...
==> Auto-updated Homebrew!  
Updated 1 tap (homebrew/core).  
==> New Formulae  
libbsd  
==> Updated Formulae  
Updated 18 formulae.  

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

Edit 2: Created a folder called 'Home-brew' in /opt/ and opened terminal there, tried sudo and everything:

oresttokovenko@Orests-MacBook-Pro-2 Homebrew % sudo chmod 755          
Password:
usage:  chmod [-fhv] [-R [-H | -L | -P]] [-a | +a | =a  [i][# [ n]]] mode|entry file ...
    chmod [-fhv] [-R [-H | -L | -P]] [-E | -C | -N | -i | -I] file ...
oresttokovenko@Orests-MacBook-Pro-2 Homebrew % https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
zsh: no such file or directory: https://github.com/Homebrew/brew/tarball/master
tar: could not chdir to 'homebrew'

oresttokovenko@Orests-MacBook-Pro-2 Homebrew % curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0    254      0 --:--:-- --:--:-- --:--:--   255
  0 1979k    0   598    0     0    682      0  0:49:32 --:--:--  0:49:32   682tar: could not chdir to 'homebrew'

  1 1979k    1 33478    0     0  34728      0  0:00:58 --:--:--  0:00:58  364k
curl: (23) Failed writing body (0 != 1370)
oresttokovenko@Orests-MacBook-Pro-2 Homebrew % sudo curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0    348      0 --:--:-- --:--:-- --:--:--   348
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0tar: could not chdir to 'homebrew'

  1 1979k    1 34138    0     0  41887      0  0:00:48 --:--:--  0:00:48  129k
curl: (23) Failed writing body (0 != 1370)

Answer

user3479219 picture user3479219 · Dec 20, 2020

I've used the script written by Noah Rubin;

/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa/raw/48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"

worked like a charm! Here is his youtube video on this topic for more info; https://youtu.be/nv2ylxro7rM

Edit: Forgot to mention, this script installs the homebrew into /opt/homebrew