{"id":4319,"date":"2020-11-29T10:42:59","date_gmt":"2020-11-29T16:42:59","guid":{"rendered":"https:\/\/dev.iachieved.it\/iachievedit\/?p=4319"},"modified":"2020-11-29T10:42:59","modified_gmt":"2020-11-29T16:42:59","slug":"yes-you-can-run-homebrew-on-an-m1-mac","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/yes-you-can-run-homebrew-on-an-m1-mac\/","title":{"rendered":"Yes You Can Run Homebrew on an M1 Mac"},"content":{"rendered":"<p>One of the reasons I took the plunge and bought an M1-based Mac is to test out its performance and suitability as a <i>developer<\/i>.  An essential developer application on the Mac is <a href=\"https:\/\/brew.sh\">Homebrew<\/a>, the &#8220;missing package manager for macOS.&#8221; Although you <a href=\"https:\/\/github.com\/Homebrew\/brew\/issues\/7857\">cannot install Homebrew today to manage ARM-compiled packages<\/a>, you can install Homebrew in the <i>Rosetta<\/i> environment and leverage the x86 packages.<\/p>\n<p>I can&#8217;t take credit for coming up with the idea, that would go to <a href=\"https:\/\/osxdaily.com\/2020\/11\/18\/how-run-homebrew-x86-terminal-apple-silicon-mac\/\">OSX Daily<\/a>, but I have a few improvements to share.  I&#8217;m going to use <a href=\"https:\/\/iterm2.com\/\">iTerm2<\/a>, and so should you.<\/p>\n<p>Right click on your iTerm application icon and select <strong>Duplicate<\/strong>. Rename <strong>iTerm copy<\/strong> to something like <strong>iTerm x86<\/strong> or <strong>iTerm Rosetta<\/strong>.<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/iTerm_Rosetta.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4320\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/iTerm_Rosetta.png\" alt=\"\" width=\"609\" height=\"456\" \/><\/a><\/p>\n<p>Now, right click on your new iTerm icon and click on <strong>Get Info<\/strong> and then check <strong>Open using Rosetta<\/strong>.<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/openUsingRosetta.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4321\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/openUsingRosetta.png\" alt=\"\" width=\"263\" height=\"556\" \/><\/a><\/p>\n<p>Open your <strong>iTerm Rosetta<\/strong> application and install Homebrew!  Once installed you should be able to use <code>brew install<\/code> in the <strong>iTerm Rosetta<\/strong> application and use those installed packages seamlessly between the two environments.  You <em>won&#8217;t<\/em>, however, be able to use <code>brew install<\/code> in your arm64 <strong>iTerm<\/strong> application (you&#8217;ll get <code>Error: Cannot install in Homebrew on ARM processor in Intel default prefix<\/code>).<\/p>\n<h2>Keeping Track<\/h2>\n<p>If you&#8217;re working in both x86 and ARM environments on your M1 Mac it is easy to lose track which iTerm you are in. We can use a little <code>zsh<\/code>-foo to help us out. Add the following snippet to the end of your <code>~\/.zshrc<\/code>:<\/p>\n<pre class=\"toolbar-overlay:false lang:sh decode:true \">\n_ARCH=$(arch)\nPROMPT=\"$_ARCH $PROMPT\"\n# Requires iterm2\nif [[ \"$_ARCH\" == \"i386\" ]]; then\n  echo -ne \"\\033]1337;SetColors=bg=0071C5\\007\"\nfi\n<\/pre>\n<p>This little snippet takes advantage of iTerm2&#8217;s <a href=\"https:\/\/iterm2.com\/documentation-escape-codes.html\">custom escape codes<\/a> by setting the background to <a href=\"\">Intel blue<\/a> if the <a href=\"\"><code>arch<\/code><\/a> command returns <code>i386<\/code> (which it does if running in Rosetta).<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/itermI386.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/itermI386.png\" alt=\"\" width=\"585\" height=\"121\" class=\"aligncenter size-full wp-image-4326\" \/><\/a><\/p>\n<p>We can do one better, however, by changing our iTerm Rosetta icon.  Create your own icon, or, right-click the image below and select <strong>Copy Image<\/strong>.  Then right-click your <strong>iTerm Rosetta<\/strong> application and select <strong>Get Info<\/strong>.  In the upper-left click on the icon until you see a highlight around it and then paste the new icon image (Command-V).<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/RosettaBlue.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/RosettaBlue.png\" alt=\"\" width=\"256\" height=\"256\" class=\"aligncenter size-full wp-image-4328\" \/><\/a><\/p>\n<p>Launch your <strong>iTerm Rosetta<\/strong> application and it&#8217;s much easier to distinguish between it and your &#8220;native&#8221; version.<\/p>\n<p><a href=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/itermVsitermR.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dev.iachieved.it\/iachievedit\/wp-content\/uploads\/2020\/11\/itermVsitermR.png\" alt=\"\" width=\"423\" height=\"300\" class=\"aligncenter size-full wp-image-4330\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the reasons I took the plunge and bought an M1-based Mac is to test out its performance and suitability as a developer. An essential developer application on the Mac is Homebrew, the &#8220;missing package manager for macOS.&#8221; Although you cannot install Homebrew today to manage ARM-compiled packages, you can install Homebrew in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,99,22],"tags":[],"class_list":["post-4319","post","type-post","status-publish","format-standard","hentry","category-apple","category-arm","category-hacking"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/4319"}],"collection":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/comments?post=4319"}],"version-history":[{"count":10,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/4319\/revisions"}],"predecessor-version":[{"id":4334,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/4319\/revisions\/4334"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=4319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=4319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=4319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}