I use pyenv
to manage my Python environments and I get the following when simply running bash
.
$ bash
pyenv: bash: command not found
I was trying to troubleshoot why pipenv shell
failed with the above error, which is how I found out even bash
wasn't working. I tried updating pipenv
via brew
and ran pyenv rehash
to regenerate the shims. And bash
is definitely present.
$ which bash
/bin/bash
I expected that if pyenv
doesn't find a command, the subsequent paths specified by the PATH
environment variable will be searched. Interestingly if I execute some non-existant command I don't get a pyenv
error.
$ someboguscommand
-bash: someboguscommand: command not found
This suggests to me that pyenv
doesn't even search for a matching command in this case and the subsequent paths in PATH
are searched, so there must be some special handling with bash
.
The issue was that I had the following line in my .bashrc
, which was being invoked when running bash
. It's a line that I no longer need:
. virtualenvwrapper.sh
This was in turn invoking pyenv's virtualwrapper shim:
$ which virtualenvwrapper.sh
/Users/greg/.pyenv/shims/virtualenvwrapper.sh
That's what caused the failure. I was able to identify this by running a debug trace with bash
:
$ bash -x
+ . virtualenvwrapper.sh
++ set -e
++ '[' -n '' ']'
++ program=bash
++ [[ bash = \p\y\t\h\o\n* ]]
++ export PYENV_ROOT=/Users/greg/.pyenv
++ PYENV_ROOT=/Users/greg/.pyenv
++ exec /usr/local/Cellar/pyenv/1.2.13_1/libexec/pyenv exec bash
pyenv: bash: command not found
Thank you for the useful comments "that other guy", Charles Duffy, and rje!