Why 'whereis' and 'which' don't show me location of command?

The which utility only searches your existing path for files, so if you cannot type "nvm" and have it run nvm, then which will not locate it.

On the other hand, whereis searches a hardcoded list of paths for the program, its manual page, and its source directory. It is possible that whereis will find something if nvm is not in your path, but if nvm is not in the hardcoded list of paths whereis searches, it will similarly be unsuccessful.

As you imply, find is a much more flexible utility for searching any path you desire for any type of file you can specify. If there is an nvm executable anywhere on your system, find can be used to hunt it down, regardless of it being in your system path.

A fourth option to look into would be the locate command, which uses an indexed database of files on your system to quickly find a file anywhere on your system, with a similarly simple invocation to which or whereis, e.g. locate nvm


If you've used curl to install nvm (and possibly other methods), it will install itself as a set of shell functions in your home directory, in a hidden folder called .nvm/nvm.sh. As it is not a command (explained in the other answers) this is why whereis and which fail to find it. Note that the same directory has a Readme.markdown which contains quite a bit of detailed information about nvm.

This is the script you can curl to install nvm: https://raw.githubusercontent.com/creationix/nvm/v0.17.3/install.sh

I had the same problem and poking through that revealed where it was installing itself, so that might be a useful method for finding out where other commands live when they are not actually commands.

This is great explanation by the author of nvm about how nvm.sh works:

https://github.com/creationix/nvm/issues/521

In short, nvm is a collection of shell functions, and even though it has the .sh extension, is not actually a shell script. This is why it does not have executable permissions (and should not be changed). To run it, it instead must be 'sourced':

. ~/.nvm/nvm.sh

The dot is a synonym for the 'source' command. Sourcing it makes the functions within the file available to the current shell. If for instance you need to run nvm from a shell script, which opens a new shell for the duration of the script, you will need to source nvm in the file because it won't be available otherwise.


Not directly related to the question, but sometimes which fails to find a file even though the file is on your path, and you can successfully execute the command in your shell. This can happen if you have used shell expansions on your path: your shell will use them but which may not.

For example, which will fail to find executables in in this directory (where ~ is expanded by your shell to your home directory): export PATH="$PATH:~/foo/bin"

If you're using bash, you might as well get in the habit of using type instead of which, as it doesn't seem to have this problem. See this answer for more alternatives.