Brew install --cask cmake fails in MacOS Catalina (10.15.7)

Having trouble with your macos to upgrade or install CMake 4.* 
or latest and got stuck since you have Cmake 3.15 or order installed?

Error similar too,
==> Installing Cask cmake
==> Moving App 'CMake.app' to '/Applications/CMake.app'
==> Backing App 'CMake.app' up to '/usr/local/Caskroom/cmake/4.0.2/CMake.app'
==> Removing App '/Applications/CMake.app'
==> Purging files for version 4.0.2 of Cask cmake
Error: It seems there is already a Binary at '/usr/local/bin/cpack'

Well if that is the case then i got you.
Check these steps:

A. rename the linked files in your `/usr/local/bin`

    $ ls -ltha /usr/local/bin/ | grep cmake
    lrwxr-xr-x    1 you  admin    32B Aug 18  2019 ctest@ -> ../Cellar/cmake/3.15.2/bin/ctest
    lrwxr-xr-x    1 you  admin    32B Aug 18  2019 cpack@ -> ../Cellar/cmake/3.15.2/bin/cpack
    lrwxr-xr-x    1 you  admin    32B Aug 18  2019 cmake@ -> ../Cellar/cmake/3.15.2/bin/cmake
    lrwxr-xr-x    1 you  admin    33B Aug 18  2019 ccmake@ -> ../Cellar/cmake/3.15.2/bin/ccmake
    
    //
    // simply rename with these commands
    //
    $ cd /usr/local/bin/
    $ ls -ltha | grep cmake| awk '{print $9}' | sed 's/@//'  |  | xargs -i{} mv {} bak-{}
    
    //
    // verify files looks like these
    //
    $ ls -ltha | grep cmake
    lrwxr-xr-x    1 you  admin    32B Aug 18  2019 bak-ctest@ -> ../Cellar/cmake/3.15.2/bin/ctest
    lrwxr-xr-x    1 you  admin    32B Aug 18  2019 bak-cpack@ -> ../Cellar/cmake/3.15.2/bin/cpack
    lrwxr-xr-x    1 you  admin    32B Aug 18  2019 bak-cmake@ -> ../Cellar/cmake/3.15.2/bin/cmake
    lrwxr-xr-x    1 you  admin    33B Aug 18  2019 bak-ccmake@ -> ../Cellar/cmake/3.15.2/bin/ccmake

B. rename the linked manpage7 `/usr/local/share/man/man7`

    $ cd /usr/local/share/man/man7
    $ ls -ltha | grep cmake 
    lrwxr-xr-x   1 you  admin    62B Jun  8 23:35 cpack@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cpack-generators.7
    lrwxr-xr-x   1 you  admin    61B Jun  8 23:35 cmake-variables.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-variables.7
    lrwxr-xr-x   1 you  admin    62B Jun  8 23:35 cmake-toolchains.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-toolchains.7
    lrwxr-xr-x   1 you  admin    58B Jun  8 23:35 cmake-server.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-server.7
    lrwxr-xr-x   1 you  admin    54B Jun  8 23:35 cmake-qt.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-qt.7
    ... // stil many but they were in the same pattern
    
    //
    // simply rename with these commands
    //
    $ ls -ltha | grep cmake| awk '{print $9}' | sed 's/@//'  |  | xargs -i{} mv {} bak-{}
    
    //
    // verify files looks like these
    //
    $ ls -ltha | grep cmake
    lrwxr-xr-x   1 you  admin    62B Jun  8 23:35 bak-cpack@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cpack-generators.7
    lrwxr-xr-x   1 you  admin    61B Jun  8 23:35 bak-cmake-variables.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-variables.7
    lrwxr-xr-x   1 you  admin    62B Jun  8 23:35 bak-cmake-toolchains.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-toolchains.7
    lrwxr-xr-x   1 you  admin    58B Jun  8 23:35 bak-cmake-server.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-server.7
    lrwxr-xr-x   1 you  admin    54B Jun  8 23:35 bak-cmake-qt.7@ -> ../../../Cellar/cmake/3.15.2/share/man/man7/cmake-qt.7
    ...

C. rename the linked manpage1 `/usr/local/share/man/man1`

    $ ls -ltha /usr/local/share/man/man1/ | grep cmake
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 ctest.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/ctest.1
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 cpack.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/cpack.1
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 cmake.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/cmake.1
    lrwxr-xr-x    1 you  admin    52B Jun  8 23:35 ccmake.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/ccmake.1
    
    //
    // simply rename with these commands
    //
    $ cd /usr/local/share/man/man7
    $ ls -ltha | grep cmake| awk '{print $9}' | sed 's/@//'  |  | xargs -i{} mv {} bak-{}
    
    //
    // verify files looks like these
    //
    $ ls -ltha | grep cmake
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 bak-cmake.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/cmake.1
    lrwxr-xr-x    1 you  admin    52B Jun  8 23:35 bak-ccmake.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/ccmake.1

    //
    // IMPORTANT!
    // ctest and cpack somehow out of our pattern then do it manually
    //
    $ ls -ltha | grep ctest | awk '{print $9}' | sed 's/@//'  |  | xargs -i{} mv {} bak-{}
    $ ls -ltha | grep cpack | awk '{print $9}' | sed 's/@//'  |  | xargs -i{} mv {} bak-{}
    $ ls -ltha | grep cmake
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 bak-cmake.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/cmake.1
    lrwxr-xr-x    1 you  admin    52B Jun  8 23:35 bak-ccmake.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/ccmake.1
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 bak-ctest.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/ctest.1
    lrwxr-xr-x    1 you  admin    51B Jun  8 23:35 bak-cpack.1@ -> ../../../Cellar/cmake/3.15.2/share/man/man1/cpack.1

Re-run your `$ brew install --cask cmake` shud works.

Comments