<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Homebrew on 修远</title><link>https://blog.l6l6.xyz/tags/homebrew/</link><description>Recent content in Homebrew on 修远</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Mon, 08 Aug 2022 09:56:18 +0800</lastBuildDate><atom:link href="https://blog.l6l6.xyz/tags/homebrew/index.xml" rel="self" type="application/rss+xml"/><item><title>M1 芯片 Mac 上 Homebrew 安装教程</title><link>https://blog.l6l6.xyz/p/mac-arm-homebrew/</link><pubDate>Mon, 08 Aug 2022 09:56:18 +0800</pubDate><guid>https://blog.l6l6.xyz/p/mac-arm-homebrew/</guid><description>&lt;img src="https://s2.loli.net/2022/08/08/LOgElda9GxYisVC.png" alt="Featured image of post M1 芯片 Mac 上 Homebrew 安装教程" />&lt;h2 id="安装-arm-版-homebrew">安装 ARM 版 Homebrew
&lt;/h2>&lt;p>&lt;code>ARM&lt;/code>版&lt;code>Homebrew&lt;/code>需要安装在&lt;code>/opt/homebrew&lt;/code>路径下，早期的时候需要手动创建目录执行命令，目前使用最新脚本不需要手动操作。直接执行：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">/bin/bash -c &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>然后还需设置环境变量，具体操作步骤如下，一定要仔细阅读。
PS: 终端类型根据执行命令&lt;code>echo $SHELL&lt;/code>显示的结果：&lt;/p>
&lt;ul>
&lt;li>&lt;code>/bin/bash&lt;/code> =&amp;gt; &lt;code>bash&lt;/code> =&amp;gt; &lt;code>.bash_profile&lt;/code>&lt;/li>
&lt;li>&lt;code>/bin/zsh&lt;/code> =&amp;gt; &lt;code>zsh&lt;/code> =&amp;gt; &lt;code>.zprofile&lt;/code>
&lt;strong>如果遇到环境变量无效问题，建议回过头来查看终端类型，再做正确的设置。&lt;/strong>
从 macOS Catalina(10.15.x) 版开始，Mac使用&lt;code>zsh&lt;/code>作为默认&lt;code>Shell&lt;/code>，使用&lt;code>.zprofile&lt;/code>，所以对应命令：&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s1">&amp;#39;eval &amp;#34;$(/opt/homebrew/bin/brew shellenv)&amp;#34;&amp;#39;&lt;/span> &amp;gt;&amp;gt; ~/.zprofile
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">eval&lt;/span> &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>/opt/homebrew/bin/brew shellenv&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>如果是macOS Mojave 及更低版本，并且没有自己配置过zsh，使用&lt;code>.bash_profile&lt;/code>：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s1">&amp;#39;eval &amp;#34;$(/opt/homebrew/bin/brew shellenv)&amp;#34;&amp;#39;&lt;/span> &amp;gt;&amp;gt; ~/.bash_profile &lt;span class="nb">eval&lt;/span> &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>/opt/homebrew/bin/brew shellenv&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="安装-x86-版-homebrew">安装 X86 版 Homebrew
&lt;/h2>&lt;p>因为目前很多软件包没有支持&lt;code>ARM&lt;/code>架构，我们也可以考虑使用&lt;code>x86&lt;/code>版的&lt;code>Homebrew&lt;/code>。
在命令前面添加&lt;code>arch -x86_64&lt;/code>，就可以按 X86 模式执行该命令，比如：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">arch -x86_64 /bin/bash -c &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="多版本共存">多版本共存
&lt;/h2>&lt;p>如果你同时安装了 ARM 和 X86 两个版本，那你需要设置别名，把命令区分开。
同样是&lt;code>.zprofile&lt;/code>或者&lt;code>.bash_profile&lt;/code>里面添加：
至于操作哪个文件，请参考前文关于终端类型的描述，下文如有类似文字，保持一样的操作。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">alias abrew=&amp;#39;arch -arm64 /opt/homebrew/bin/brew&amp;#39;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">alias ibrew=&amp;#39;arch -x86_64 /usr/local/bin/brew&amp;#39;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;code>abrew&lt;/code>、&lt;code>ibrew&lt;/code>可以根据你的喜好自定义。
然后再执行&lt;code>source ~/.zprofile&lt;/code>或&lt;code>source ~/.bash_profile&lt;/code>命令更新文件。&lt;/p>
&lt;h2 id="设置镜像">设置镜像
&lt;/h2>&lt;blockquote>
&lt;p>注意：本文中的安装脚本会设置中科大源镜像，如果你也想设置cask和bottles的镜像，请按下面注释部分选择执行代码。&lt;/p>
&lt;/blockquote>
&lt;p>执行时根据实际情况修改&lt;code>&amp;quot;$(brew --repo)&amp;quot;&lt;/code>代码中的&lt;code>brew&lt;/code>。
意思是如果你只是使用一个版本&lt;code>Homebrew&lt;/code>，直接执行命令即可，如果你想多个版本共存或者使用了别名，就把&lt;code>brew&lt;/code>关键字替换为别名名称，如前面的&lt;code>abrew&lt;/code>、&lt;code>ibrew&lt;/code>。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># brew&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git -C &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>brew --repo&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span> remote set-url origin https://mirrors.ustc.edu.cn/brew.git
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># core&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git -C &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>brew --repo homebrew/core&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span> remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># cask&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git -C &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>brew --repo homebrew/cask&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span> remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># bottles for zsh 和下面2选1&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s1">&amp;#39;export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles&amp;#39;&lt;/span> &amp;gt;&amp;gt; ~/.zprofile
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">source&lt;/span> ~/.zprofile
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># bottles for bash 和上面2选1&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s1">&amp;#39;export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles&amp;#39;&lt;/span> &amp;gt;&amp;gt; ~/.bash_profile
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">source&lt;/span> ~/.bash_profile
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><follow_challenge><feedId>68852316548471808</feedId><userId>55783422475808768</userId></follow_challenge></channel></rss>