<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>软件包管理 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/%E8%BD%AF%E4%BB%B6%E5%8C%85%E7%AE%A1%E7%90%86/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Sat, 20 Jan 2024 16:52:09 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] MacOS上的Homebrew记录</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e4%b8%8a%e7%9a%84homebrew%e8%ae%b0%e5%bd%95/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e4%b8%8a%e7%9a%84homebrew%e8%ae%b0%e5%bd%95/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sat, 20 Jan 2024 16:52:09 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[MacOS]]></category>
		<category><![CDATA[软件包管理]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=14050</guid>

					<description><![CDATA[<p>本文记录了MacOS上的软件包管理器Homebrew的若干琐事。</p>
<blockquote>
<p>
		Homebrew 是一个自由和开源的软件包管理系统，专为 macOS 设计，用于简化软件安装过程。它允许用户容易地安装、更新和卸载各种软件包，包括命令行工具、开发工具和常用库。Homebrew 通过 GitHub 维护，并且它的软件包是从 GitHub 仓库中获取的。</p>
</blockquote>
<p><span id="more-14050"></span><br />
<span style="color: rgb(255, 0, 0);">➤</span>&#160;安装 Homebrew 并保持最新<br />
在macOS里，为了方便快捷地安装各种软件包，首先你要装好Homebrew。<br />
安装Homebrew的过程此处不赘述，请参考Homebrew官网。<br />
如果你早已安装过，那么注意要保持它最新：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; letter-spacing: 0px; color: rgb(62, 62, 62); line-height: 1.6; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="padding: 0px; font-size: inherit; width: 1066.23px; margin-top: 0px; margin-bottom: 0px; color: inherit; line-height: inherit;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">brew&#160;update
</code></pre>
</section>
<p>这个过程可能耗时较长。<br />
如果你不更新，可能会在用 brew install xxx&#160;安装软件包的时候，看到类似于下面的提示：</p>
<blockquote>
<div>
		==&#62; Searching for similarly named formulae...</div>
<div>
		Error: No similarly named formulae found.</div>
<div>
		Error: No available formula or cask with the name &#34;grc&#34;.</div></blockquote>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e4%b8%8a%e7%9a%84homebrew%e8%ae%b0%e5%bd%95/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>本文记录了MacOS上的软件包管理器Homebrew的若干琐事。</p>
<blockquote>
<p>
		Homebrew 是一个自由和开源的软件包管理系统，专为 macOS 设计，用于简化软件安装过程。它允许用户容易地安装、更新和卸载各种软件包，包括命令行工具、开发工具和常用库。Homebrew 通过 GitHub 维护，并且它的软件包是从 GitHub 仓库中获取的。</p>
</blockquote>
<p><span id="more-14050"></span><br />
<span style="color: rgb(255, 0, 0);">➤</span>&nbsp;安装 Homebrew 并保持最新<br />
在macOS里，为了方便快捷地安装各种软件包，首先你要装好Homebrew。<br />
安装Homebrew的过程此处不赘述，请参考Homebrew官网。<br />
如果你早已安装过，那么注意要保持它最新：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; letter-spacing: 0px; color: rgb(62, 62, 62); line-height: 1.6; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="padding: 0px; font-size: inherit; width: 1066.23px; margin-top: 0px; margin-bottom: 0px; color: inherit; line-height: inherit;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">brew&nbsp;update
</code></pre>
</section>
<p>这个过程可能耗时较长。<br />
如果你不更新，可能会在用 brew install xxx&nbsp;安装软件包的时候，看到类似于下面的提示：</p>
<blockquote>
<div>
		==&gt; Searching for similarly named formulae...</div>
<div>
		Error: No similarly named formulae found.</div>
<div>
		Error: No available formula or cask with the name &quot;grc&quot;.</div>
<div>
		==&gt; Searching for a previously deleted formula (in the last month)...</div>
<div>
		Error: No previously deleted formula found.</div>
<div>
		==&gt; Searching taps on GitHub...</div>
<div>
		Error: No formulae found in taps.</div>
</blockquote>
<div>
	也就是说Homebrew找不到软件包。</div>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤</span>&nbsp;设置 GitHub&nbsp;密钥，让Homebrew可以正常安装软件<br />
如果你没有设置过 GitHub&nbsp;密钥，当你执行 brew install xxx&nbsp;命令来安装软件的时候，会报错：</p>
<blockquote>
<div>
		Error: GitHub</div>
<div>
		The GitHub credentials in the macOS keychain may be invalid.</div>
<div>
		Clear them with:</div>
<div>
		&nbsp; printf &quot;protocol=https\nhost=github.com\n&quot; | git credential-osxkeychain erase</div>
<div>
		Or create a personal access token:</div>
<div>
		&nbsp; https://github.com/settings/tokens/new?scopes=gist,public_repo&amp;description=Homebrew</div>
<div>
		and then set the token as: export HOMEBREW_GITHUB_API_TOKEN=&quot;your_new_token&quot;</div>
</blockquote>
<p>大概意思就是，你需要到上面的这个GitHub链接里设置、生成一个token，然后把&nbsp;<span style="color: rgb(0, 0, 255);">HOMEBREW_GITHUB_API_TOKEN</span>&nbsp;这个环境变量设置成你生成的那个token。<br />
照做就得了。生成token之后，编辑&nbsp;~/.bash_profile&nbsp;文件，添加一行：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; letter-spacing: 0px; color: rgb(62, 62, 62); line-height: 1.6; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="padding: 0px; font-size: inherit; width: 1066.23px; margin-top: 0px; margin-bottom: 0px; color: inherit; line-height: inherit;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); overflow-wrap: inherit !important; word-break: inherit !important;">export</span>&nbsp;HOMEBREW_GITHUB_API_TOKEN=xxx
</code></pre>
</section>
<p>其中，xxx&nbsp;代表你在GitHub上生成的那个 token。<br />
这样做之后，你理应可以用 brew install&nbsp;来正常安装软件了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤</span>&nbsp;Homebrew加速：设置国内镜像<br />
由于Homebrew默认使用的是GitHub上的仓库，对于国内用户来说，访问速度可能会比较慢。国内有一些机构提供了Homebrew的镜像，可以用来加速软件包的下载和安装：中科大镜像、清华镜像、阿里云镜像等。<br />
以阿里云镜像为例：<br />
替换 brew.git：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; letter-spacing: 0px; color: rgb(62, 62, 62); line-height: 1.6; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="padding: 0px; font-size: inherit; width: 1066.23px; margin-top: 0px; margin-bottom: 0px; color: inherit; line-height: inherit;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">git&nbsp;-C&nbsp;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); overflow-wrap: inherit !important; word-break: inherit !important;">&quot;<span class="hljs-variable" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(98, 151, 85); overflow-wrap: inherit !important; word-break: inherit !important;">$(brew&nbsp;--repo)</span>&quot;</span>&nbsp;remote&nbsp;<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); overflow-wrap: inherit !important; word-break: inherit !important;">set</span>-url&nbsp;origin&nbsp;https://mirrors.aliyun.com/homebrew/brew.git
</code></pre>
</section>
<p>替换&nbsp;homebrew-core.git：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; letter-spacing: 0px; color: rgb(62, 62, 62); line-height: 1.6; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="padding: 0px; font-size: inherit; width: 1066.23px; margin-top: 0px; margin-bottom: 0px; color: inherit; line-height: inherit;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">git&nbsp;-C&nbsp;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); overflow-wrap: inherit !important; word-break: inherit !important;">&quot;<span class="hljs-variable" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(98, 151, 85); overflow-wrap: inherit !important; word-break: inherit !important;">$(brew&nbsp;--repo&nbsp;homebrew/core)</span>&quot;</span>&nbsp;remote&nbsp;<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); overflow-wrap: inherit !important; word-break: inherit !important;">set</span>-url&nbsp;origin&nbsp;https://mirrors.aliyun.com/homebrew/homebrew-core.git
</code></pre>
</section>
<p>替换&nbsp;homebrew-cask.git（如果需要）：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; letter-spacing: 0px; color: rgb(62, 62, 62); line-height: 1.6; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="padding: 0px; font-size: inherit; width: 1066.23px; margin-top: 0px; margin-bottom: 0px; color: inherit; line-height: inherit;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">git&nbsp;-C&nbsp;<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); overflow-wrap: inherit !important; word-break: inherit !important;">&quot;<span class="hljs-variable" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(98, 151, 85); overflow-wrap: inherit !important; word-break: inherit !important;">$(brew&nbsp;--repo&nbsp;homebrew/cask)</span>&quot;</span>&nbsp;remote&nbsp;<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); overflow-wrap: inherit !important; word-break: inherit !important;">set</span>-url&nbsp;origin&nbsp;https://mirrors.aliyun.com/homebrew/homebrew-cask.git
</code></pre>
</section>
<p>然后再执行 brew update&nbsp;来更新本地仓库。</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：<br />
<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="color: rgb(77, 77, 77); font-size: 13px; width: 200px; height: 200px;" /><br />
以及我的微信视频号：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="" src="https://www.codelast.com/wechat_shipinhao_qr_code.jpg" style="text-align: center; width: 200px; height: 199px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e4%b8%8a%e7%9a%84homebrew%e8%ae%b0%e5%bd%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
