"cmake –version" points to /usr/bin/cmake while "which cmake" points to /usr/local/bin

Issue

I am trying to upgrade cmake on my linux computer. Here is the command I used.

Remove the old cmake:

sudo apt purge --auto-remove cmake

Download and extracted cmake-3.13.3.tar.gz from https://cmake.org/download/

Then in the extracted cmake folder:

./bootstrap
make 
sudo make install 

when I did cmake --version it returns

bash: /usr/bin/cmake: No such file or directory

which indicates that no cmake executable exists in /usr/bin. However when I run which cmake it returns

/usr/local/bin/cmake

And that does exist.

How do I have the command cmake point to /usr/local/bin/cmake?

My $PATH shows

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Edit: different from the other question since I know exactly where the cmake executable is just that --version and which have different effect.

Solution

In bash you can use hash -r so that it forgets all remembered locations of previously executed commands.

Answered By – bbu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published