"command not found" when pipenv shell, .bashrc is empty
See original GitHub issueOS: macOS
As I understand from reading on SO and some issues here, pipenv
launches non-login shells, which means it should ignore .bash_profile
, and only use .bashrc
:
“Because Pipenv only reads bashrc and that’s it. Use the above workarounds.” - @uranusjr in #844
My .bashrc
is empty.
I’ve been moving around stuff in my dotfiles just to get pipenv
to work properly but I’m not having too much success. This is the error I see when pipenv shell
is run in a project directory:
bash: prompt_git: command not found
prompt_git
is a function defined in .bash_prompt
, which is sourced in .bash_profile
. So why is pipenv
still complaining?
In .bash_profile
, which pipenv
seems to be using, I’ve also tried doing conditionally sourcing this .bash_prompt
just to satisfy pipenv
:
if shopt -q login_shell; then
if [[ $- == *i* ]]; then
if [ -f ~/.bash_prompt ]; then
source ~/.bash_prompt
fi
fi
fi
But that isn’t helping either.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
No, the
$PROMPT_COMMAND
environment variable was inherited from the parent shell. The general recommendation is to make.bash_prompt
available in both.bashrc
and.bash_profile
.Yeah I know, it’s very confusing, that’s how Bash works. A child process inherits the parent’s environment (unless explicitly set otherwise), so all environment variables are automatically available in a sub-shell without configuration. Bash functions, however, are not part of the environment, and are therefore not inherited.
Bash internally (as I understand it) stores
$PROMPT_COMMAND
as a string, andeval
it for every prompt. It does not carry the referenced function with it when copied into the child shell (only the name, as a string), so the child shell gets a reference error when trying toeval
it.I read here that it is also possible to use
export -f
to make functions available in a child shell. I am not sure whether that works withpipenv shell
, however.