You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
venv bug: Function “_old_fish_prompt” does not exist when activating venv in child process #93858
Should output: functions: Function “_old_fish_prompt” does not exist
Cause
I think I've identified the reason for the bug:
The environment variables set in activate.fish are exported to child processes (script uses set -gx to set the variables).
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
still seeing this in 2024 on deactivate. just a normal shell, not tmux or nested or anything.
fish: Unknown command: _old_fish_prompt
fish:
_old_fish_prompt
^~~~~~~~~~~~~~~^
in command substitution
in function '_warp_prompt'
called on line 1 of file /var/folders/zq/vyffd7255m38x2mbmvvd102w0000gn/T/.tmpP4yVid
in command substitution
called on line 120 of file /var/folders/zq/vyffd7255m38x2mbmvvd102w0000gn/T/.tmpP4yVid
in function 'warp_precmd'
in event handler: handler for generic event 'fish_prompt'
fish: Unknown command
set -l prompt (_old_fish_prompt)
^~~~~~~~~~~~~~~~~^
in function '_warp_prompt'
called on line 1 of file /var/folders/zq/vyffd7255m38x2mbmvvd102w0000gn/T/.tmpP4yVid
in command substitution
called on line 120 of file /var/folders/zq/vyffd7255m38x2mbmvvd102w0000gn/T/.tmpP4yVid
in function 'warp_precmd'
in event handler: handler for generic event 'fish_prompt'
I've have similar problem and my workaround is, deactivate > fish > source "desired/venv".
This is work around, not solution.
Would love to hear solution if there is any
⋊> ~/c/webscrape on dev ⨯ source /Users/burak/code/webscrape/webscrap
evenv/bin/activate.fish
functions: Function '_old_fish_prompt' does not exist
~/code/webscrape/webscrapevenv/bin/activate.fish (line 18):
functions -c _old_fish_prompt fish_prompt
^
in function 'deactivate' with arguments 'nondestructive'
called on line 30 of file ~/code/webscrape/webscrapevenv/bin/activate.fish
from sourcing file ~/code/webscrape/webscrapevenv/bin/activate.fish
(Type 'help functions' for related documentation)
functions: Function 'fish_prompt' does not exist
~/code/webscrape/webscrapevenv/bin/activate.fish (line 47):
functions -c fish_prompt _old_fish_prompt
^
from sourcing file ~/code/webscrape/webscrapevenv/bin/activate.fish
(Type 'help functions' for related documentation)
fish: Unknown command: _old_fish_prompt
~/code/webscrape/webscrapevenv/bin/activate.fish (line 71):
_old_fish_prompt
^~~~~~~~~~~~~~~^
in function 'fish_prompt'
in command substitution
(webscrapevenv) deactivate (base) 23:02:44
functions: Function '_old_fish_prompt' does not exist
~/code/webscrape/webscrapevenv/bin/activate.fish (line 18):
functions -c _old_fish_prompt fish_prompt
^
in function 'deactivate'
(Type 'help functions' for related documentation)
burak@Buraks-MacBook-Pro.local /Users/burak/code/webscrape > fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
⋊> ~/c/webscrape on dev ⨯ source /Users/burak/code/webscrape/webscrap
evenv/bin/activate.fish
Activity
vsajip commentedon Jun 15, 2022
Please do, and thanks for the report.
gh-93858: Prevent error when activating venv in nested fish instances (…
pythongh-93858: Prevent error when activating venv in nested fish ins…
pythongh-93858: Prevent error when activating venv in nested fish ins…
[3.11] gh-93858: Prevent error when activating venv in nested fish in…
[3.10] gh-93858: Prevent error when activating venv in nested fish in…
banteg commentedon Apr 1, 2024
still seeing this in 2024 on
deactivate. just a normal shell, not tmux or nested or anything.thomasbbrunner commentedon Apr 9, 2024
@banteg Which Python version are you using? Which system?
Also, are you using venv or virtualenv to create your environment?
banteg commentedon Apr 9, 2024
can't replicate anymore, sorry for bothering
wonjoonSeol commentedon May 8, 2024
I am also getting the same error message when using
deactivate:I used poetry env use command to create the environment.
mac OS.
Update: The issue seem to do with Warp terminal. Running the same commands on different terminal has no issue.
Obsessivex commentedon Jun 11, 2024
I've have similar problem and my workaround is, deactivate > fish > source "desired/venv".
This is work around, not solution.
Would love to hear solution if there is any