繁体   English   中英

使用 Homebrew 安装 Cmake 3.19.2

[英]Install Cmake 3.19.2 with Homebrew

我正在尝试安装旧版本的 CMake 来编译需要它的软件( https://github.com/horosproject/horos

如果您使用brew install cmake它将安装 3.20 版本,但我需要安装 3.19.2 才能使编译工作。

你会认为这很容易,但我一直在努力。 以下是我尝试过的一些事情:

curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/481056b12a782e11b43670f406b1674b05990d0d/Formula/cmake.rb && brew install ./cmake.rb

此命令下载原始公式,然后尝试根据我看到的一些答案进行安装,因为brew versions命令已被弃用。

尝试运行上面的命令会给我以下错误:

Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Error: Failed to load cask: ./cmake.rb
Cask 'cmake' is unreadable: wrong constant name #<Class:0x00007fe8f24621b0>
Warning: Treating ./cmake.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2
##O#- #                                                                       
curl: (22) The requested URL returned error: 404 
Error: Failed to download resource "cmake_bottle_manifest"
Download failed: https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2

我认为它不起作用,因为我需要对清单下载进行身份验证,但这应该在之前没有任何问题或类似要求的情况下工作,让我相信我可能做错了什么。

任何帮助表示赞赏! 成功的结果将导致cmake --version说它是版本 3.19.2。 另外我想确认我知道 cmake 是 100% 的问题,因为我在我的另一台机器上编译了 Horos。

这让我有另一种可能从那里复制 cmake 但我不确定如何正确地做到这一点或这有多难? (如果这甚至是正确的程序,更不用说这对这个问题的未来读者没有帮助)。

额外信息:

https://github.com/Homebrew/homebrew-core/blob/2be111d6b85b6a72565b4883cafb4f171c6e6b8f/Formula/cmake.rb

这是我为旧版本的 cmake 找到的公式示例。

https://github.com/Homebrew/homebrew-core/commits/master/Formula/cmake.rb

以上是所有不同版本的列表

奇怪的部分是......如果你在最新的瓶子 3.20 上使用这种方法,它就可以工作!

更新::

所以我正在阅读另一个答案,看来这个错误是由 cURL 过时引起的。 所以我更新到最新的 cURL (确认它仍然适用于最新版本),然后回到旧版本,现在我得到了一个不同的错误。

https://superuser.com/questions/1647213/brew-install-fails-downloading-from-ghcr-io-macos-mojave

以上是我了解 cURL 版本修复的地方。

现在我的错误是这样的:

curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/d1a6d9cec03e43ae276ab6423fba0b91b69a1945/Formula/cmake.rb && brew install ./cmake.rb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1961  100  1961    0     0  46229      0 --:--:-- --:--:-- --:--:-- 50282
/usr/local/Homebrew/Library/Homebrew/formulary.rb:84:in `rescue in block in load_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:77:in `block in load_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:90:in `load_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:110:in `load_formula_from_path'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:195:in `load_file'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:185:in `klass'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:180:in `get_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:404:in `factory'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:98:in `load_formula_or_cask'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:57:in `block in to_formulae_and_casks'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `each'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `flat_map'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `to_formulae_and_casks'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:158:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:122:in `<main>'
Error: cmake: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead

运行 brew style --fix./cmake.rb 将修复上面的错误,但我再次得到完全相同的错误!

brew install ./cmake.rb
Error: Failed to load cask: ./cmake.rb
Cask 'cmake' is unreadable: wrong constant name #<Class:0x00007fc2138b7f90>
Warning: Treating ./cmake.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2
curl: (22) The requested URL returned error: 404                              

Error: Failed to download resource "cmake_bottle_manifest"
Download failed: https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2

我在沮丧中束手无策,似乎在兜圈子。 任何帮助是极大的赞赏!

brew install./cmake.rb会尝试安装一个瓶子,它显然已经不存在了。 尝试使用brew install -s./cmake.rb从源代码安装。

❯ cmake --version
zsh: command not found: cmake

❯ curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/481056b12a782e11b43670f406b1674b05990d0d/Formula/cmake.rb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2006  100  2006    0     0  26394      0 --:--:-- --:--:-- --:--:-- 26394

❯ brew install -s ./cmake.rb
Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Error: Failed to load cask: ./cmake.rb
Cask 'cmake' is unreadable: wrong constant name #<Class:0x00007ffab488a5c0>
Warning: Treating ./cmake.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/sphinx-doc/manifests/4.0.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/sphinx-doc/blobs/sha256:df254b910ef155cbf68f614a903a7601c583b108252dd2d3a21d304577ceec42
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:df254b910ef155cbf68f614a903a7601c583b108252dd2d3a21d304577ceec42?se=2021-06-07T01%3A15%3A00Z&sig=qO3%2Be9wjDZFGb8G0TMkWRdx%2FsSzXGGmIoQoVXBSKTLc%3D&sp=
######################################################################## 100.0%
==> Downloading https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2.tar.gz
==> Downloading from https://github-releases.githubusercontent.com/537699/e5e69f80-3f8c-11eb-8f66-b847f2092348?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210607%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=
######################################################################## 100.0%
Warning: cmake 3.20.3 is available and more recent than version 3.19.2.
==> Installing dependencies for cmake: sphinx-doc
==> Installing cmake dependency: sphinx-doc
==> Pouring sphinx-doc--4.0.2.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/sphinx-doc/4.0.2: 3,885 files, 55.9MB
==> Installing cmake
Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.19.2 --no-system-libs --parallel=12 --datadir=/share/cmake --docdir=/share/doc/cmake --mandir=/share/man --sphinx-build=/usr/local/opt/sphinx-doc/bin/sphinx-build --sphinx-html --sphinx
==> make
==> make install
Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake
==> Summary
🍺  /usr/local/Cellar/cmake/3.19.2: 6,376 files, 63.9MB, built in 4 minutes 22 seconds
Removing: /Users/nega/Library/Caches/Homebrew/cmake--3.19.2.tar.gz... (8.8MB)
==> Caveats
==> cmake
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake

❯ cmake --version
cmake version 3.19.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

❯

当然,您进行的下一次brew upgrade可能会消除这种情况。

您可以安装 KitWare 提供的 macOS 应用程序包:

❯ curl -O https://cmake.org/files/v3.19/cmake-3.19.2-macos-universal.dmg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 61.6M  100 61.6M    0     0  6340k      0  0:00:09  0:00:09 --:--:-- 13.3M

❯ open cmake-3.19.2-macos-universal.dmg

或者正如@the-swine 在他们的评论中所建议的那样,通过源代码安装 CMake。

❯ curl -O https://cmake.org/files/v3.19/cmake-3.19.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9047k  100 9047k    0     0  1301k      0  0:00:06  0:00:06 --:--:-- 2035k

❯ tar xf cmake-3.19.2.tar.gz

❯ cd cmake-3.19.2

~/cmake-3.19.2 ❯ less README.rst

~/cmake-3.19.2 ❯ ./bootstrap --prefix=/opt/cmake && make && sudo make install

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM