Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got the default OpenSSL 9.8 (Mac OS X 10.6.8) and decided to install the newest version (1.0.1) via MacPorts (sudo port install openssl).

These are console output of which and whereis commands:

$ whereis openssl
/usr/bin/openssl

(this is default system's one)

$which openssl
/opt/local/bin/openssl

(this is installed via MacPorts)

$ openssl version
OpenSSL 1.0.1c 10 May 2012

(there is mac port's version in PATH)

Why are different paths returned for whereis and which, and is this okay? Is there any way to get equal results?

share|improve this question
add comment

1 Answer 1

up vote 9 down vote accepted

In the manpage of whereis, it clearly says (emphasis mine):

The whereis utility checks the standard binary directories for the specified programs, printing out the paths of any it finds.

The path searched is the string returned by the sysctl(8) utility for the ``user.cs_path'' string

Contrary to that, which is the tool commonly used to check where a binary is for your user's path.

The which utility takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked.

That explains your difference, since /opt/local/bin is not a system-wide "standard" path—after all, MacPorts is a completely optional installation—and sysctl only has /usr/bin:/bin:/usr/sbin:/sbin in its user.cs_path per default.

In general, stick to which or which -a to find a binary rather than using whereis.


You can theoretically change user.cs_path through

sysctl -w user.cs_path=/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

but I don't know if that is such a good idea.

share|improve this answer
    
Thanks, you've highlited that "The whereis utility checks the standard binary directories" - that is the answer! couldn't vote up for you answer cause of small reputation(( –  jctim May 29 '12 at 9:56
    
Don't worry, you'll surely get more reputation soon. Welcome to Super User! :) –  slhck May 29 '12 at 10:37
    
Have the same problem with psql on OS X - unfortunately user.cs_path is not writable. Getting closer to my solution though, thanks for such a useful answer! –  user208769 Jun 25 '12 at 15:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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