Skip to content
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

venv bug: Function “_old_fish_prompt” does not exist when activating venv in child process #93858

Closed
thomasbbrunner opened this issue Jun 15, 2022 · 1 comment · Fixed by #93931
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@thomasbbrunner
Copy link
Contributor

thomasbbrunner commented Jun 15, 2022

Bug report

Looked for similar issues and could not find any.

Steps to reproduce bug:

  1. activate venv
  2. spawn child fish process (or start tmux session)
  3. activate same venv
source activate.fish
fish
source activate.fish

Should output:
functions: Function “_old_fish_prompt” does not exist

Cause

I think I've identified the reason for the bug:

  1. The environment variables set in activate.fish are exported to child processes (script uses set -gx to set the variables).
  2. However, the function _old_fish_prompt is not exported to child processes.

So, when we run fish from another fish session (such as in tmux), the variables set in activate.fish are present in the child process, but the functions are not.

Fix

I've written a fix for this, which is to test if the _old_fish_prompt function exists before attempting to delete it. I can make a PR with this fix.

Also, the implementation from virtualenv does not suffer from this bug. They check if the function exists before deleting it.

Your environment

Ubuntu 22.04 amd64
Python 3.10.4
Python and venv packages installed from apt

@thomasbbrunner thomasbbrunner added the type-bug An unexpected behavior, bug, or error label Jun 15, 2022
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Jun 15, 2022
@vsajip
Copy link
Member

vsajip commented Jun 15, 2022

I can make a PR with this fix.

Please do, and thanks for the report.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 18, 2022
…tances (pythonGH-93931)

(cherry picked from commit 1172172)

Co-authored-by: Thomas B. Brunner <thomasbbrunner@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 18, 2022
…tances (pythonGH-93931)

(cherry picked from commit 1172172)

Co-authored-by: Thomas B. Brunner <thomasbbrunner@gmail.com>
vsajip pushed a commit that referenced this issue Oct 18, 2022
…stances (GH-93931) (GH-98402)

Co-authored-by: Thomas B. Brunner <thomasbbrunner@gmail.com>
vsajip pushed a commit that referenced this issue Oct 18, 2022
…stances (GH-93931) (GH-98403)

Co-authored-by: Thomas B. Brunner <thomasbbrunner@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants