Joseph Astrahan
Joseph Astrahan

Reputation: 9082

Install Cmake 3.19.2 with Homebrew

I'm trying to install an older version of CMake to compile a software that requires it (https://github.com/horosproject/horos)

If you use brew install cmake it will install 3.20 versions, but I need to install 3.19.2 to get the compilation to work.

You would think this would be easy but I have been struggling. Here are some things I have tried:

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

This command downloads the raw formula and then attempts to install based on some answers I have seen since the brew versions command is deprecated.

Attempting to run the command above gives me the following errors:

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

I think it's not working because I need authentication for the manifest download, but this should have worked before without any issues or anything like this required, leaving me to believe I'm probably doing something incorrect.

Any help is appreciated! A successful result would result in cmake --version saying it's version 3.19.2. Also I want to confirm that I know cmake is 100% the issue since I have the compilation of Horos working on my other machine.

Which leaves another possibility of me copying the cmake from there but I'm not sure how to do that correctly or how hard that would be? (if that is even proper procedure, not to mention that would not help future readers of this question).

Extra Info:

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

Here is an example of a formula I found for an older version of cmake.

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

above is a list of all the different versions

strange part is... if you use this method with the newest bottle 3.20 it works!

UPDATE::

So I was reading another answer and it appears this error is caused by cURL being out of date. So I updated to the latest cURL (confirmed it still works with the newest version), then went back to the old and now I get a different error.

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

The above is where I learned about the cURL version fix.

Now my error is this:

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

running brew style --fix ./cmake.rb will fix the error above but then I get the exact same error again!

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

I'm at wits end in frustration and seem to be going in circles. Any help is greatly appreciated!

Upvotes: 4

Views: 10388

Answers (1)

nega
nega

Reputation: 2747

brew install ./cmake.rb will try to install a bottle, which obviously doesn't exist anymore. Try installing from source with 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).

❯

Of course, the next brew upgrade you do will probably wipe that out.

You could install the macOS app bundle that KitWare provides:

❯ 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

Or as @the-swine suggests in their comment, install CMake via source.

❯ 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

Upvotes: 5

Related Questions