Skip to content

Instantly share code, notes, and snippets.

@nrubin29
Last active November 24, 2023 11:27
Show Gist options
  • Save nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa to your computer and use it in GitHub Desktop.
Save nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa to your computer and use it in GitHub Desktop.
Install Native Homebrew on Apple Silicon M1
# We'll be installing Homebrew in the /opt directory.
cd /opt
# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew
# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
# Add the Homebrew bin directory to the PATH. If you don't use zsh, you'll need to do this yourself.
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
@nrubin29
Copy link
Author

nrubin29 commented Nov 24, 2020

Run this command on your terminal to use this script:

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

@kamusis
Copy link

kamusis commented Nov 29, 2020

Hi Noah
Did you get the error when Homebrew tried to build Python 3.9 on M1 silicon? When I try to install the 1st app , my favorite htop, using "brew install htop", I got this error:

==> Installing htop dependency: [email protected]
==> Patching
==> Applying arm64-3.9.patch
patching file Lib/_osx_support.py
patching file Lib/ctypes/macholib/dyld.py
patching file Lib/ctypes/test/test_macholib.py
patching file Lib/distutils/tests/test_build_ext.py
patching file Lib/test/test_bytes.py
patching file Lib/test/test_platform.py
patching file Lib/test/test_posix.py
patching file Lib/test/test_time.py
patching file Lib/test/test_unicode.py
patching file Mac/BuildScript/build-installer.py
patching file Mac/README.rst
patching file Mac/Tools/pythonw.c
patching file Modules/_ctypes/callbacks.c
patching file Modules/_ctypes/callproc.c
patching file Modules/_ctypes/ctypes.h
patching file Modules/_ctypes/malloc_closure.c
patching file Modules/getpath.c
patching file Modules/posixmodule.c
patching file Modules/timemodule.c
patching file Python/bootstrap_hash.c
patching file Python/pytime.c
patching file configure
patching file configure.ac
patching file pyconfig.h.in
patching file setup.py
==> ./configure --prefix=/opt/homebrew/Cellar/[email protected]/3.9.0_2 --enable-ipv6 --datarootdir=/opt/homebrew/Cellar/[email protected]/3.9.0_2/share --datadir=/opt/homebrew/Cellar/python@
==> make
Last 15 lines from /Users/kamus/Library/Logs/Homebrew/[email protected]/02.make:
    self.run_command(cmd_name)
  File "/private/tmp/[email protected]/Python-3.9.0/Lib/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/private/tmp/[email protected]/Python-3.9.0/Lib/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/tmp/[email protected]/Python-3.9.0/Lib/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/private/tmp/[email protected]/Python-3.9.0/./setup.py", line 470, in build_extensions
    self.detect_modules()
  File "/private/tmp/[email protected]/Python-3.9.0/./setup.py", line 1807, in detect_modules
    self.detect_readline_curses()
  File "/private/tmp/[email protected]/Python-3.9.0/./setup.py", line 1038, in detect_readline_curses
    (tuple(int(n) for n in dep_target.split('.')[0:2])
AttributeError: 'int' object has no attribute 'split'
make: *** [sharedmods] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!

Traceback (most recent call last):
	22: from /opt/homebrew/Library/Homebrew/build.rb:224:in `<main>'
	21: from /opt/homebrew/Library/Homebrew/build.rb:135:in `install'
	20: from /opt/homebrew/Library/Homebrew/utils.rb:500:in `with_env'
	19: from /opt/homebrew/Library/Homebrew/build.rb:140:in `block in install'
	18: from /opt/homebrew/Library/Homebrew/formula.rb:1207:in `brew'
	17: from /opt/homebrew/Library/Homebrew/formula.rb:2209:in `stage'
	16: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/forwardable.rb:230:in `stage'
	15: from /opt/homebrew/Library/Homebrew/resource.rb:89:in `stage'
	14: from /opt/homebrew/Library/Homebrew/resource.rb:114:in `unpack'
	13: from /opt/homebrew/Library/Homebrew/resource.rb:207:in `mktemp'
	12: from /opt/homebrew/Library/Homebrew/mktemp.rb:63:in `run'
	11: from /opt/homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
	10: from /opt/homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
	 9: from /opt/homebrew/Library/Homebrew/resource.rb:119:in `block in unpack'
	 8: from /opt/homebrew/Library/Homebrew/formula.rb:2229:in `block in stage'
	 7: from /opt/homebrew/Library/Homebrew/utils.rb:500:in `with_env'
	 6: from /opt/homebrew/Library/Homebrew/formula.rb:2230:in `block (2 levels) in stage'
	 5: from /opt/homebrew/Library/Homebrew/formula.rb:1214:in `block in brew'
	 4: from /opt/homebrew/Library/Homebrew/build.rb:172:in `block (2 levels) in install'
	 3: from /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/[email protected]:151:in `install'
	 2: from /opt/homebrew/Library/Homebrew/formula.rb:2016:in `system'
	 1: from /opt/homebrew/Library/Homebrew/formula.rb:2016:in `open'
/opt/homebrew/Library/Homebrew/formula.rb:2080:in `block in system': Failed executing: make (BuildError)
	10: from /opt/homebrew/Library/Homebrew/brew.rb:150:in `<main>'
	 9: from /opt/homebrew/Library/Homebrew/brew.rb:162:in `rescue in <main>'
	 8: from /opt/homebrew/Library/Homebrew/exceptions.rb:474:in `dump'
	 7: from /opt/homebrew/Library/Homebrew/exceptions.rb:420:in `issues'
	 6: from /opt/homebrew/Library/Homebrew/exceptions.rb:424:in `fetch_issues'
	 5: from /opt/homebrew/Library/Homebrew/utils/github.rb:321:in `issues_for_formula'
	 4: from /opt/homebrew/Library/Homebrew/utils/github.rb:309:in `search_issues'
	 3: from /opt/homebrew/Library/Homebrew/utils/github.rb:424:in `search'
	 2: from /opt/homebrew/Library/Homebrew/utils/github.rb:238:in `open_api'
	 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse': 767: unexpected token at '{ (JSON::ParserError)
  "total_count": 2'
	10: from /opt/homebrew/Library/Homebrew/brew.rb:150:in `<main>'
	 9: from /opt/homebrew/Library/Homebrew/brew.rb:162:in `rescue in <main>'
	 8: from /opt/homebrew/Library/Homebrew/exceptions.rb:474:in `dump'
	 7: from /opt/homebrew/Library/Homebrew/exceptions.rb:420:in `issues'
	 6: from /opt/homebrew/Library/Homebrew/exceptions.rb:424:in `fetch_issues'
	 5: from /opt/homebrew/Library/Homebrew/utils/github.rb:321:in `issues_for_formula'
	 4: from /opt/homebrew/Library/Homebrew/utils/github.rb:309:in `search_issues'
	 3: from /opt/homebrew/Library/Homebrew/utils/github.rb:424:in `search'
	 2: from /opt/homebrew/Library/Homebrew/utils/github.rb:238:in `open_api'
	 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse': Failed to parse JSON response (GitHub::Error)
767: unexpected token at '{
  "total_count": 2'

I don't know how to fix it, would you please give some advices?

@kamusis
Copy link

kamusis commented Nov 29, 2020

Incase needed ,here is the brew config output.

brew config                                                                                                                              183  23:46:18 
HOMEBREW_VERSION: 2.5.12-275-gef75518
ORIGIN: https://github.com/Homebrew/brew
HEAD: ef755182bbd11bf8f49b0139d089046596ab8fb7
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 8d3a0574b1757b6a7a2027d7c3c33dd3b8ac09ed
Core tap last commit: 30 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_REPOSITORY: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit dunno
Clang: 12.0 build 1200
Git: 2.24.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-arm64
CLT: 12.2.0.0.1.1604076827
Xcode: N/A
Rosetta 2: false

@nol166
Copy link

nol166 commented Dec 25, 2020

Thank you for making this

@Mikelem
Copy link

Mikelem commented May 15, 2021

Thanks for this! It's great...except I get this ("No such file or directory") every time I do anything with brew, for example %brew doctor
% brew doctor
/opt/homebrew/bin/brew: line 11: cd: /usr/local/Homebrew/bin: No such file or directory
Your system is ready to brew.
Any thoughts? brew works fine (or does it?) but...that message!

@kamusis
Copy link

kamusis commented Jun 3, 2021

Thanks for this! It's great...except I get this ("No such file or directory") every time I do anything with brew, for example %brew doctor
% brew doctor
/opt/homebrew/bin/brew: line 11: cd: /usr/local/Homebrew/bin: No such file or directory
Your system is ready to brew.
Any thoughts? brew works fine (or does it?) but...that message!

do you have any "/usr/local/bin/brew" file exists? or maybe you tried to install brew into "/usr/local/" as in x86 arch, and you didn't remove them clearly?

@thirusha112
Copy link

I can't install it please some can help me with this situation I want to run f-adsk20”. for get an activation code of AutoCAD please help me.
thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment