-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python Venv and PS1 Update Fails In Emas #70
Comments
Using separate bash process for completion appears to fix the problem |
Could you give more details about what you're doing and what is going wrong? Why did you write "bc.org"? Using separate bash process will leave the prompt alone, so definitely, it'll fix any issues with setting PS1, but I'd like to understand and hopefully fix the problem. |
Original issue did state what I was doing, will attach again in case it
got lost.
I'll also include the "activate" bash script generated by Python it's
juggling PS1 so it can restore it when the virtual env is deactivated
and I suspect that that is getting confused by what bash-completion is
doing.
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/raman/.local/share/pipx/venvs"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(venvs) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(venvs) "
export VIRTUAL_ENV_PROMPT
fi
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null
…--
My earlier notes:
* Python Venv, Bash-Completions and PS1
1. I use bash-completions in Emacs 30 built from ***@***.***
2. I use Python 3.10 and run into an issue when activating a Virtual Env
3. If I create the env as python3 -m venv venv, activating it in a
shell outside Emacs updates the prompt.
4. However the activate script that python3 sets up does not change
the prompt in Bash running under Emacs.
5. I think it is getting confused somehow by the custom PS1 prompt
that bash-completions uses
6. I think it's this one:
#+begin_src emacs-lisp
bash-completion--ps1 "'==emacs==ret=$?==.'"
#+end_src
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bc.org
The text was updated successfully, but these errors were encountered: