2

First I installed the version of cmake from the repos:

sudo apt-get install cmake

Then I discovered that I need feature of cmake that is not in the older version, so I unstalled cmake:

sudo apt-get remove cmake

And installed from source:

wget http://www.cmake.org/files/v3.3/cmake-3.3.2.tar.gz
tar -xzf cmake-3.3.2.tar.gz
cd cmake-3.3.2/
./configure 
make
sudo make install

Now, running sudo cmake . correctly generates a makefile.

But running cmake . genereates an error:

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

reinstalling the repository version and comparing the output of:

cmake --version
sudo cmake --version 

indicates that the from-source version is being run when sudo is invoked, and the repository version is being run when it is not.

What is going on here?

I checked that $PATH includes /usr/local/bin before /usr/bin, but I'm not sure where else to look.

1
  • Edit your question and add the output of sudo $SHELL -c 'whoami; command -v cmake' and the output of command -v cmake – A.B. Oct 9 '15 at 8:10
1

bash keeps a hash table of recently executed files and their location, so it doesn't need to search PATH every time a command is invoked.

You can see the currently kept hashes with hash. Look for cmake in there. To clear the hash table and make bash search PATH anew, do

hash -r 

See also this wonderful explanation.

1
  • I wish I had run hash before running hash -r so I could try and make a guess about how it got messed up. Instead I just ran hash -r and found that things were working properly after that. Thanks for the help. – MatrixManAtYrService Oct 12 '15 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.