Skip to content

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

Closed
@thomasbbrunner

Description

@thomasbbrunner

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

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions