Luc Shelton

Homebrew and Anaconda: Configuring for Apple M1 and Intel Silicon

Homebrew and Anaconda: Configuring for Apple M1 and Intel Silicon

Homebrew and Anaconda: Configuring for Apple M1 and Intel Silicon

Homebrew and Anaconda: Configuring for Apple M1 and Intel Silicon

5 Minute(s) to read
Posted 24 months ago Updated 24 months ago 5 Minute(s) to read 296 comments

This is a quick article that will serve as a brain dump for how I've recently configured my /bin/bash profile for using Homebrew Package Manager with both M1 and Intel Silicon (with x86 emulated using Rosetta).

Installation Locations

Depending on which CPU architecture you are installing Homebrew Package Manager with will determine where brew is installed. By default, brew will be installed to the following locations.

M1 Silicon Installation Path

If you are using brew on Apple M1 silicon, then the default installation script will install Homebrew Package Manager to the following paths.

#!/bin/bash
/opt/homebrew/bin
/opt/homebrew/Caskroom

Intel Silicon Installation Path

If you are using Homebrew Package Manager on Intel silicon, or through Rosetta emulation, then you will notice that Homebrew is installed to the following paths when you use the default installation script that is available from the official homepage.

#!/bin/bash
/usr/local/bin/brew
/usr/local/Caskroom

Configuring Bash

Now that we know where brew is installed, we can configure bash to automatically load the relevant shell environment depending on which architecture is being used. This is useful if you have multiple copies of iTerm2 (for example), whereby one copy may be configured to launch with Rosetta emulation. If your Terminal instance (including iTerm2) is launched with Rosetta emulation, it will automatically attempt to use Homebrew at the listed installation path above (under "Intel Silicon"). However, because both installations are at different paths, we need some logic to detect which architecture (emulated or not) is being actively used, so we know which shell environment to load.

Refer to the logic below. It uses a command called "uname" to detect which CPU architecture is actively in use. Based on the resulting value, it will then load the relevant shell environment. x86_64 is considered to be Intel Silicon, and arm64 is considered to be Apple M1.

Homebrew Shell Environment

The snippet below describes the logic for automatically loading Homebrew shell environment depending on the architecture.

#!/bin/bash
if [[ "$(uname -m)" == "x86_64" ]]; then
	echo "Loading: Homebrew (x86)"
	eval "$(/usr/local/bin/brew shellenv)"
    CONDA_BREW_PATH=/usr/local/Caskroom/miniconda
else
	echo "Loading: Homebrew (ARM)"
	eval "$(/opt/homebrew/bin/brew shellenv)"
    CONDA_BREW_PATH=/opt/homebrew/Caskroom/miniconda
fi

Anaconda Shell Environment

The snippet below describes the logic (typically generated by Anaconda) for loading the relevant shell environment.

#!/bin/bash
if [[ "$(uname -m)" == "x86_64" ]]; then
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/usr/local/Caskroom/miniforge/base/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f "/usr/local/Caskroom/miniforge/base/etc/profile.d/conda.sh" ]; then
            . "/usr/local/Caskroom/miniforge/base/etc/profile.d/conda.sh"  # commented out by conda initialize
        else
            export PATH="/usr/local/Caskroom/miniforge/base/bin:$PATH"  # commented out by conda initialize
        fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<
elif [[ "$(uname -m)" == "arm64" ]]; then
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/opt/homebrew/Caskroom/miniforge/base/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f "/opt/homebrew/Caskroom/miniforge/base/etc/profile.d/conda.sh" ]; then
            . "/opt/homebrew/Caskroom/miniforge/base/etc/profile.d/conda.sh"  # commented out by conda initialize
        else
            export PATH="/opt/homebrew/Caskroom/miniforge/base/bin:$PATH"  # commented out by conda initialize
        fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<
fi

Configuring iTerm to Launch with Rosetta Emulation

If you are running on Apple M1 silicon, you can still run the same applications with x86 emulation by using Rosetta. You can install Rosetta from the command-line by running the following command.

#!/bin/bash
/usr/sbin/softwareupdate --install-rosetta --agree-to-license

And now you can create a copy of your iTerm installation, and modify the copy to launch with Rosetta emulation. Refer to the screenshots below for greater reference.

A picture of Applications in macOS finder, with a duplicate or copy of iTerm.

A picture of "Applications" in macOS finder, with a duplicate or copy of iTerm.

With your duplicate instance of iTerm, you can then modify the properties so that it launches with Rosetta emulation.

After you've duplicated your iTerm installation and renamed it appropriately, you will then have to modify the properties so that it launches with Rosetta.

After you've duplicated your iTerm installation and renamed it appropriately, you will then have to modify the properties so that it launches with Rosetta.

Additionally, if you want to be able to interchangeably use either Homebrew installations while using one kind of architecture over the other, then you can make use of the following aliases that can be added to your ~/.profile file. It should be noted that this snippet includes support for pyenv, a tool that is used for managing multiple installations of Python on the same machine.

#!/bin/bash
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
alias ibrew='arch -x86_64 /usr/local/bin/brew'
alias mbrew='arch -arm64e /opt/homebrew/bin/brew'

There you have it. You should be able to use Homebrew with both architectures from the same Apple M1 machine.



Comments

Comments

leading increase develop
[url=http://bestonlineseosolutionbd.blogspot.com/2014/02/forum-posting-sites-list.html]http://bestonlineseosolutionbd.blogspot.com/2014/02/forum-posting-sites-list.html[/url]
[url=http://kyrgauyldy-karasai.mektebi.kz/meroprijatija-prazdniki/156-9-b-synyp-oushylary-1-mamyr-brlk-kn.html]http://kyrgauyldy-karasai.mektebi.kz/meroprijatija-prazdniki/156-9-b-synyp-oushylary-1-mamyr-brlk-kn.html[/url]
[url=http://alla-print.ru/index.php?subaction=userinfo&user=azojevoj]http://alla-print.ru/index.php?subaction=userinfo&user=azojevoj[/url]
[url=http://djsmartfield.de/index.php?option=com_easybookreloaded]http://djsmartfield.de/index.php?option=com_easybookreloaded[/url]
[url=http://itw.fludilka.su/viewtopic.php?id=650#p2834]http://itw.fludilka.su/viewtopic.php?id=650#p2834[/url]
[url=http://matthes-foto.de/4images/member.php?action=showprofile&user_id=24080]http://matthes-foto.de/4images/member.php?action=showprofile&user_id=24080[/url]
[url=http://36-taraz.mektebi.kz/oushylara/709--tosan-bojynsha-blm-sapasy.html]http://36-taraz.mektebi.kz/oushylara/709--tosan-bojynsha-blm-sapasy.html[/url]
[url=http://returngain.com/forum/index.php?action=profile;u=209141]http://returngain.com/forum/index.php?action=profile;u=209141[/url]
[url=http://olddle.orkclub.ru/index.php?subaction=userinfo&user=obufywun]http://olddle.orkclub.ru/index.php?subaction=userinfo&user=obufywun[/url]
[url=http://41-ileaud.mektebi.kz/main/94-shezhre-zherjy-brlestgn-aptalyy.html]http://41-ileaud.mektebi.kz/main/94-shezhre-zherjy-brlestgn-aptalyy.html[/url]
[url=http://inter-illusion.com/forum/user/19482-agomyg]http://inter-illusion.com/forum/user/19482-agomyg[/url]
[url=http://rkb.minzdravrso.ru/about/forum/user/348258/]http://rkb.minzdravrso.ru/about/forum/user/348258/[/url]
[url=http://penelopetessuti.ru/index.php?subaction=userinfo&user=olumuvu]http://penelopetessuti.ru/index.php?subaction=userinfo&user=olumuvu[/url]
[url=http://15-taraz.mektebi.kz/meroprijatija-prazdniki/727-zhas-lan-jymy-stazdardy-mektep-yzmetkerlern-merekelermen-ttytapalystaryn-ajtty.html]http://15-taraz.mektebi.kz/meroprijatija-prazdniki/727-zhas-lan-jymy-stazdardy-mektep-yzmetkerlern-merekelermen-ttytapalystaryn-ajtty.html[/url]
[url=http://www.markusragger.at/chess/index.php/kforum/jm-corporate-template/523027#523166]http://www.markusragger.at/chess/index.php/kforum/jm-corporate-template/523027#523166[/url]

Vladislav Soloviev is political scientist, analyst, economic columnist and blogger.
[url=https://www.youtube.com/watch?v=GDMElapbaoc]vladislav soloviev CEO[/url]
The main field of his research activities is political and economic development in conditions of world turbulence.
See the link http://www.jiexin.cn/auth.asp?https://www.youtube.com/watch?v=GDMElapbaoc
[url=https://sattaupking.com/Terms-of-Service/Terms-of-Service/]Blogger Vladislav Soloviev: who is the best CEO of the year?[/url] b0a2bc0

upbound change change
<a href="http://prosat.ru/modules.html?name=Journal&file=display&jid=10507">http://prosat.ru/modules.html?name=Journal&file=display&jid=10507</a>
<a href="http://nes-apk.com/index.php?subaction=userinfo&user=usoren">http://nes-apk.com/index.php?subaction=userinfo&user=usoren</a>
<a href="https://www.informetr.ru/forum/viewtopic.php?pid=2456103#p2456103">https://www.informetr.ru/forum/viewtopic.php?pid=2456103#p2456103</a>
<a href="http://dluckybastard.blogspot.com/2018/05/peningkatan-pada-kebijakan-privasi-dan.html">http://dluckybastard.blogspot.com/2018/05/peningkatan-pada-kebijakan-privasi-dan.html</a>
<a href="http://retail-ts.ru/index.php?subaction=userinfo&user=unizyp">http://retail-ts.ru/index.php?subaction=userinfo&user=unizyp</a>
<a href="http://pspkaizoupsppsp.blog18.fc2.com/blog-entry-115.html#comment1726">http://pspkaizoupsppsp.blog18.fc2.com/blog-entry-115.html#comment1726</a>
<a href="http://59.shymkent-mektebi.kz/o-shkole/21-otbasy-trbie-basymektep-trbie-zharshysy.html">http://59.shymkent-mektebi.kz/o-shkole/21-otbasy-trbie-basymektep-trbie-zharshysy.html</a>
<a href="https://www.gisweb.ru/forum/messages/forum19/topic12437/message93312/12437-lazernaya-gravirovka-na-lyubom-materiale-v-sankt_peterburge?result=new#message93312">https://www.gisweb.ru/forum/messages/forum19/topic12437/message93312/12437-lazernaya-gravirovka-na-lyubom-materiale-v-sankt_peterburge?result=new#message93312</a>
<a href="http://molchanovonews.ru/index.php?subaction=userinfo&user=yxyfuj">http://molchanovonews.ru/index.php?subaction=userinfo&user=yxyfuj</a>
<a href="http://behzistiardabil.ir/index.php?subaction=userinfo&user=otomeniwy">http://behzistiardabil.ir/index.php?subaction=userinfo&user=otomeniwy</a>
<a href="http://paperpanacherd.blogspot.com/2019/02/gina-k-designs-february-2019-new.html">http://paperpanacherd.blogspot.com/2019/02/gina-k-designs-february-2019-new.html</a>
<a href="https://fleur.borda.ru/?1-4-0-00000468-000-0-0-1667674145">https://fleur.borda.ru/?1-4-0-00000468-000-0-0-1667674145</a>
<a href="http://www.peritofisioterapeuta.com/2019/09/advogado-veja-as-razoes-para-buscar-um.html">http://www.peritofisioterapeuta.com/2019/09/advogado-veja-as-razoes-para-buscar-um.html</a>
<a href="http://takumi222.achoo.jp/blog/sb/log/eid3.html?">http://takumi222.achoo.jp/blog/sb/log/eid3.html?</a>
<a href="http://terra-bashkiria.com/forum/?PAGE_NAME=profile_view&UID=113544">http://terra-bashkiria.com/forum/?PAGE_NAME=profile_view&UID=113544</a>

high arise mature
<a href="http://makulatura63.ru/index.php?subaction=userinfo&user=itixu">http://makulatura63.ru/index.php?subaction=userinfo&user=itixu</a>
<a href="http://dasbodenlosefass.blogspot.com/2010/07/6-eintrag.html">http://dasbodenlosefass.blogspot.com/2010/07/6-eintrag.html</a>
<a href="http://vozrastnet.ru/forum/user/38892/">http://vozrastnet.ru/forum/user/38892/</a>
<a href="https://aktivnoe.forum24.ru/?1-7-0-00007578-000-0-0-1666622516">https://aktivnoe.forum24.ru/?1-7-0-00007578-000-0-0-1666622516</a>
<a href="http://bykovo.mektebi.kz/roditelyam/114-instrukciya-dlya-roditeley-po-priemu-detey-v-1-klass.html">http://bykovo.mektebi.kz/roditelyam/114-instrukciya-dlya-roditeley-po-priemu-detey-v-1-klass.html</a>
<a href="http://mtpkrskstate.ru/forum/user/97831/">http://mtpkrskstate.ru/forum/user/97831/</a>
<a href="http://81.almatybala.kz/o-detskom-sade/administraciya/45-zaveduyuschaya-abdykalykova-gulmira-kulbaevna.html">http://81.almatybala.kz/o-detskom-sade/administraciya/45-zaveduyuschaya-abdykalykova-gulmira-kulbaevna.html</a>
<a href="http://redpumpkinstudio.blogspot.com/2010/04/postcard-guestbook.html">http://redpumpkinstudio.blogspot.com/2010/04/postcard-guestbook.html</a>
<a href="http://bioapteka.kz/page,1,2,356-balzam-listvennica-sibirskaya-podsochka-zhenskoe-dolgoletie-100-ml.html">http://bioapteka.kz/page,1,2,356-balzam-listvennica-sibirskaya-podsochka-zhenskoe-dolgoletie-100-ml.html</a>
<a href="http://www.kihashiro.com/sb/log/eid61.html?">http://www.kihashiro.com/sb/log/eid61.html?</a>
<a href="http://2-ileaud.mektebi.kz/o-detskom-sade/prepodavateli/147-tvorchestvo-zhizn-kljuch-k-ponimaniju-nedelja-associacii-jesteticheskih-predmetov.html">http://2-ileaud.mektebi.kz/o-detskom-sade/prepodavateli/147-tvorchestvo-zhizn-kljuch-k-ponimaniju-nedelja-associacii-jesteticheskih-predmetov.html</a>
<a href="http://zhumagulov-kokpiyaz.mektebi.kz/main/164-ttenshe-zhadajlar-departament.html">http://zhumagulov-kokpiyaz.mektebi.kz/main/164-ttenshe-zhadajlar-departament.html</a>
<a href="http://ulkenshygan-panfilov.mektebi.kz/main/85-lkenshyan-orta-mekteb.html">http://ulkenshygan-panfilov.mektebi.kz/main/85-lkenshyan-orta-mekteb.html</a>
<a href="http://timenextjob.blogspot.com/2016/05/video-anak-smp-mesum-di-mobil.html">http://timenextjob.blogspot.com/2016/05/video-anak-smp-mesum-di-mobil.html</a>
<a href="http://orien.info/akhbori-ojil/5261-vkd-gulandom-duhtaroni-toikro-fireb-doda-baroi-tanfursh-ba-turkija-mefiristod-video.html">http://orien.info/akhbori-ojil/5261-vkd-gulandom-duhtaroni-toikro-fireb-doda-baroi-tanfursh-ba-turkija-mefiristod-video.html</a>

Vladislav Alexandrovich Soloviev was born in 1973 in the city of Moscow, in the family of ordinary middle-level workers, his father was a designer engineer in a “Compass” construction bureau and his mother was a bookkeeper at the same company.
<a href=https://ventsmagazine.com/2022/11/30/vladislav-soloviev-biography-his-career/>vladislav soloviev biography</a>
In 1996, he successfully graduated from the Moscow Institute of Technology and Management.
See the link http://jump.5ch.net/?https://ventsmagazine.com/2022/11/30/vladislav-soloviev-biography-his-career/
<a href=https://www.entertainoz.com.au/static_pages/leave_comment/virtual-magic-show>Vladislav Soloviev. Biography</a> a69e317

Gravatar for oceattaby
oceattaby
Posted Feb 10, 2023, 5:24 AM (15 months ago)

x0euRyghXDnUKceU2JeS81cltkfqUzJb
gB3iPQ1RdH3fj2tVDgjgvOLasfY0Hxx9
5Sad3W73Ti2GFuNzKfghn1MJLiQSjYhB
ZzdsIMnmgosCTAZv371ym5vohmhMJMoA
BgZoJOwvyDhUiL1hpC40WGVZ7WNSbPX3
dHtwUkrzmWFuqaH4OU1qM55Jflmpt3Ov
jz3DQXWIOHUAqsE2pavy0hgo0otEWUyK
VvO5DVYjiKdCGTdjhkMmNc4FfzsJmYCF

Gravatar for Mypecaps
Mypecaps
Posted Feb 9, 2023, 12:17 PM (15 months ago)

eYbAntU1VSyAC2lKNiWCgZvOKWLoxtWD
YIgbiNtDWGmgbNxEY8ZS9HNz9W31VVjW
IA1k238nPwUfYsCAgXJH72XcH6JCx0ym
1EOJwBOYXQ0o2ou6ONEXS8JtFumCCt8S
yhbc7GkBCcD5D0RocpHdLktTOQMVI10A
qFVIH1kwHuB0to51HhuNYAkhbRRRMSEY
Q5mommeQxOsHutI2oLl13vyQlnOZpKqE
bbw0gvHQMqfp0M1gxhyouI17lq21WxyO

очень давно интересно

ничего особенного

не работает