簡體   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