question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"command not found" when pipenv shell, .bashrc is empty

See original GitHub issue

OS: 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
uranusjrcommented, Apr 25, 2019

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.

1reaction
uranusjrcommented, Apr 25, 2019

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, and eval 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 to eval 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 with pipenv shell, however.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Pipenv: Command Not Found - Stack Overflow
2. In command Prompt (cmd) enter PATH and check in output if the c:\users\test\appdata\roaming\python\python36\Scripts or ...
Read more >
Solving `command not found: pipenv` - Koen Woortman
Most likely you installed pipenv with pip( pip install pipenv ) without having the directory where pip installs local dependencies in your PATH....
Read more >
Pipenv & Virtual Environments
If pipenv isn't available in your shell after installation, you'll need to add the user base's binary directory to your PATH . On...
Read more >
bash - .bashrc: command not found - Super User
Short answer: it is not working because with .bashrc you are trying to execute a command named .bashrc that has to exist_ somewhere...
Read more >
bash: pyenv: command not found - You.com | The AI Search ...
The proper command to run a single shell that knows where pyenv is located and can execute it would be: RUN source /root/.bashrc...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found