Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

path

cmake

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.

like image 866
kkawabat Avatar asked Jan 29 '19 21:01

kkawabat


People also ask

How do I change my path in CMake?

CMake will use whatever path the running CMake executable is in. Furthermore, it may get confused if you switch paths between runs without clearing the cache. So what you have to do is simply instead of running cmake <path_to_src> from the command line, run ~/usr/cmake-path/bin/cmake <path_to_src> .

Where is CMake stored?

The installation directory is usually left at its default, which is /usr/local . Installing software here ensures that it is automatically available to users. It is possible to specify a different installation directory by adding -DCMAKE_INSTALL_PREFIX=/path/to/install/dir to the CMake command line.

What is Ubuntu CMake?

CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform.


1 Answers

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

like image 62
bbu Avatar answered Oct 09 '22 11:10

bbu