I wanted to update my cmake version. So I had first uninstalled it and then tried to install as given in this post by teocci.
However, it was giving some errors on entering make and now I want to uninstall it and install the previous version of cmake. I tried sudo apt-get purge cmake
. But it still remains in the system on entering cmake --version
.
What should I do?
TL;DR: Run
sudo make uninstall
in the directory where you ransudo make install
before.You followed this method of installing a different version of CMake. This is to say that you uninstalled the version provided by Ubuntu's package manager and manually downloaded, compiled, and installed it yourself from source code.
Assuming you were able to follow those instructions successfully, the version of CMake provided by Ubuntu's package manager (via the
cmake
package) is already uninstalled. Because the version that you have installed now is not provided by Ubuntu's package manager, but instead the version you compiled and installed yourself, runningsudo apt-get purge cmake
again does not remove it.Since you installed
cmake
by compiling it and then runningsudo make install
, the solution is for you to:cd
to go back to the directory where you ran that command.sudo make uninstall
.Not all software that can be installed by running
make install
has a correspondinguninstall
target letting you runmake uninstall
to remove it. But CMake does support this.1If you have deleted the folder in which you ran
sudo make install
, or otherwise changed it, then your best bet is to rebuild and reinstall it (be sure to use exactly the same version) to get back the ability to runsudo make uninstall
. That is, you would follow the same installation steps, starting from the same.tar.gz
file and passing all the same options you used (if any) to./bootstrap
. If you just ran./bootstrap
with no arguments after it, do that again. After runningsudo make install
again, which would (harmlessly) overwrite the files that were already installed with copies of themselves, you would then be able to usesudo make uninstall
.Another possible approach, which I strongly discourage you from doing, would be to try to figure out exactly what files and directories were created in the installation, and to try to remove just those files and directories but no others. If you did not pass the
--prefix
to./bootstrap
when you compiled CMake then it installed files in/usr/local
, but it is not the only program that uses that directory. It would have installed files in the various subdirectories of/usr/local
, such asbin
andlib
(and others), so aside from the situation where you know nothing else was installed into/usr/local
, this option requires a lot of work.1 It's easy to become confused about whether or not you can uninstall CMake by running
sudo make uninstall
because, by default, when you use CMake to create build scripts for your own software, nouninstall
target is generated unless you explicitly ask for one. However, CMake itself is designed to be easily uninstalled, and its source code does define those uninstall targets for itself. In theMakefile
generated from running./bootstrap
you can see:You can also search for uninstall support in its CMakeLists.txt file.
To be sure, I tested this with CMake 3.9.0, and it does work. The
uninstall
target is generated and runningsudo make uninstall
works to uninstall CMake.