无法安装新的Homebrew公式

huangapple go评论53阅读模式
英文:

Can't install new Homebrew formula

问题

I can provide the translation of the text you provided. Here's the translated text:

(Homebrew版本3.6.21)

我正在尝试创建和安装一个新的公式,但当我尝试安装它时,Homebrew首先尝试从GitHub获取公式,这当然会失败,因为它目前只存在于我的本地计算机上。

我正在尝试回滚到某个软件的旧版本,所以新的公式名为 name@x.y.z。最初,我尝试使用 brew edit 编辑现有的公式,但发现Homebrew一直使用较新版本的URL,尽管我已编辑了公式 - 这可能是因为它从GitHub获取公式并使用那个版本,而不是使用我编辑的版本。

复制步骤:

  • brew create --set-name <formula-name> <some-url>
  • 编辑公式
  • brew install -s <formula-name>

结果:

==> 正在获取 <formula-name>
curl: (22) 请求的URL返回错误:404

错误:执行时失败;`/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl \
	--disable \
	--cookie /dev/null \
	--globoff \
	--show-error \
	--user-agent Homebrew/3.6.21-164-ge42cae1\ (Macintosh; arm64 Mac OS X 13.2) curl/7.86.0 \
	--header Accept-Language:\ en \
	--fail \
	--progress-bar \
	--retry 3 \
	--location \
	--remote-time \
	--output /Users/alastaid/Library/Caches/Homebrew/Formula/<formula-name>.rb \
	https://raw.githubusercontent.com/Homebrew/homebrew-core/9a6a815e5ea0169b46e10f411ac3237740a6bbdf/Formula/<formula-name>.rb`
返回22。以下是输出:
curl: (22) 请求的URL返回错误:404

如何强制Homebrew使用我编辑/创建的公式而不是从GitHub下载?如果将来我编辑公式,如何防止Homebrew尝试重新下载我尝试测试的公式并覆盖我的更改?

英文:

(Homebrew version 3.6.21)

I'm trying to create and install a new formula, but when I try to install it Homebrew first tries to fetch the formula from Github, which of course fails because it's only on my local machine at the moment.

I'm trying to roll back to an old version of some software, so the new formula is named name@x.y.z. I initially tried editing the existing formula with brew edit, but found that Homebrew kept using the URLs for the newer version, even though I'd edited the formula - probably because it was fetching the formula from Github and using that instead of using my edited version.

Steps to reproduce:

  • brew create --set-name <formula-name> <some-url>
  • Edit the formula
  • brew install -s <formula-name>

Result:

==> Fetching <formula-name>
curl: (22) The requested URL returned error: 404

Error: Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl \
	--disable \
	--cookie /dev/null \
	--globoff \
	--show-error \
	--user-agent Homebrew/3.6.21-164-ge42cae1\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.2\)\ curl/7.86.0 \
	--header Accept-Language:\ en \
	--fail \
	--progress-bar \
	--retry 3 \
	--location \
	--remote-time \
	--output /Users/alastaid/Library/Caches/Homebrew/Formula/<formula-name>.rb \
	https://raw.githubusercontent.com/Homebrew/homebrew-core/9a6a815e5ea0169b46e10f411ac3237740a6bbdf/Formula/<formula-name>.rb`
exited with 22. Here&#39;s the output:
curl: (22) The requested URL returned error: 404

How can I force Homebrew to use my edited / created formula instead of downloading from GitHub?

And if I edit a formula in the future, how do I prevent Homebrew from trying to re-download the formula I'm trying to test and overwriting my changes?

答案1

得分: 2

我认为这个问题是因为文档尚未更新至Homebrew v4.0而导致的。我可以根据你的说明重现这个问题,以下是我的brew --version

brew --version
Homebrew 4.0.3
Homebrew/homebrew-core (git revision 63589f1a8e3; last commit 2023-02-16)
Homebrew/homebrew-cask (git revision ce33115a81; last commit 2023-02-16)

看起来已经有一个更新v4.0文档的PR,其中写着:

在开发时,你需要在任何安装命令之前设置HOMEBREW_NO_INSTALL_FROM_API=1,以强制brew使用本地仓库而不是API。

所以,不要使用之前的brew install命令,改用这个:

HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula-name>

我尝试了这个方法,它帮助我跳过了下载失败的问题。你可能仍然需要编辑你的公式以确保它能正确运行。

英文:

I believe this problem is due to the documentation not having been updated yet for homebrew v4.0. I can reproduce the problem based on your instructions, and here is my brew --version:

brew --version
Homebrew 4.0.3
Homebrew/homebrew-core (git revision 63589f1a8e3; last commit 2023-02-16)
Homebrew/homebrew-cask (git revision ce33115a81; last commit 2023-02-16)

It looks like there is a PR to update the documentation for v4.0, which says the following:

> As you are developing, you'll also need to set HOMEBREW_NO_INSTALL_FROM_API=1 before any install commands, to force brew to use the local repository instead of the API.

So instead of your previous brew install command, run this:

HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source &lt;formula-name&gt;

I tried this and it got me past the failing download. You will probably still need to edit your formula to make sure it works correctly.

huangapple
  • 本文由 发表于 2023年2月16日 09:40:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75467042.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定