how to install the cmake with specific version on WSL ubuntu 20.04

I am currently trying to link my CLion to WSL, but CLion only supported the Cmake of version 3.20.x, not the latest version, so I wonder how to downgrade my Cmake (version 3.21.3) to 3.20.x on Ubuntu

thanks for helping!


Solution 1:

Your question didn't say so, but the version (3.21.3) suggests that you are using the Snap package of cmake (not a deb package).

Here's the output of snap info cmake, edited for clarity:

[...]
channels:
  latest/stable:    3.21.3                 2021-09-21 (936) 116MB classic
  [...]                                            
  3.21/stable:      3.21.3                 2021-09-21 (936) 116MB classic
  [...]                                             
  3.20/stable:      3.20.6                 2021-09-21 (930) 115MB classic
  [...]

This tells us that you are likely using the latest/stable channel, which currently provides version 3.21.3. Version 3.20.6 is available on a different channel (the 3.20/stable channel).

  • At the moment, you cannot use multiple channels simultaneously: Installing B will remove A.

You should be able to install the 3.20.x version using:

sudo snap refresh cmake --channel=3.20/stable

And then you can return to latest using:

sudo snap refresh cmake --channel=latest/stable