Orest Tokovenko
Orest Tokovenko

Reputation: 173

How can I install Homebrew into /opt/?

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)

Upvotes: 16

Views: 24699

Answers (3)

user3479219
user3479219

Reputation: 349

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

Upvotes: 26

Charlie Niekirk
Charlie Niekirk

Reputation: 1143

Just for anyone coming across this now, I got the curl: (23) Failed writing body (0 != 1370) error multiple times until I realised I was running the curl/tar command from my home directory. If I cd into /opt and then run the command, it works as expected.

Upvotes: 0

sparkle
sparkle

Reputation: 7390

I solved it running under the Rosetta Terminal

  1. Locate the Terminal application within the Utilities folder (Finder> Go menu > Utilities)

  2. Select Terminal.app and right-click on it, then choose “Duplicate” Rename the duplicated Terminal app something obvious and distinct, like ‘Rosetta Terminal’

  3. Now select the freshly renamed ‘Rosetta Terminal’ app and right-click and choose “Get Info” (or hit Command+i)

  4. Check the box for “Open using Rosetta”, then close the Get Info window Run the “Rosetta Terminal” as usual, which will fully support Homebrew and other x86 command line apps

Upvotes: 4

Related Questions