1

I'm using zsh and have 2 ipython executables in my $PATH:

❯ which ipython
/usr/local/Caskroom/miniconda/base/bin/ipython
❯ where ipython
/usr/local/Caskroom/miniconda/base/envs/tg/bin/ipython
/usr/local/Caskroom/miniconda/base/bin/ipython

As you can see, where and which give different results on the first line, why is that?

2
  • 1
    Hmm, usually with zsh where is just whence -ca and which is whence -c. Have you aliased either? What's the result of where where and where which?
    – frabjous
    Commented Mar 31, 2022 at 16:33
  • @frabjous No, they're both zsh builtins.
    – Teddy C
    Commented Apr 1, 2022 at 9:59

1 Answer 1

2

When it comes to looking for external executables where, aka whence -ca does a full $PATH look-up for the command, while which aka whence -c relies on cached data (as exposed by the $commands special associative array).

If the /usr/local/Caskroom/miniconda/base/envs/tg/bin/ipython file was added after the cache was built, it will be missed by whence.

Doing a hash -r / rehash will invalidate that cache and you'll likely find that after that where and which agree. See the code for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .