Skip to content

deactivate not available in tmux session started from a virtual environment #103291

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

Open
nakulj opened this issue Apr 5, 2023 · 4 comments
Open
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@nakulj
Copy link

nakulj commented Apr 5, 2023

Bug report

In Fish, when starting tmux after activating a virtual environment, the deactivate command is not available in the tmux session.

$ python3 -m venv .venv
$ source .venv/bin/activate.fish
(.venv) $ tmux

This starts a tmux session with the virtual environment already activated, and working sort of correctly, but impossible to deactivate:

(.venv) $ echo $VIRTUAL_ENV
~/test/.venv
(.venv) $ which python
~/test/.venv/bin/python
(.venv) $ deactivate
fish: Unknown command: deactivate

Your environment

  • CPython versions tested on: Python 3.11.2
  • Operating system and architecture: macOS Ventura, M1
  • Fish version- 3.6.1
  • tmux version- 3.3a

Linked PRs

@nakulj nakulj added the type-bug An unexpected behavior, bug, or error label Apr 5, 2023
@arhadthedev arhadthedev added the stdlib Python modules in the Lib dir label Apr 6, 2023
@arhadthedev
Copy link
Member

@vsajip (as a venv module expert)

@nakulj
Copy link
Author

nakulj commented Apr 6, 2023

@thomasbbrunner any ideas on how to fix this? It appears related to #93858

@thomasbbrunner
Copy link
Contributor

@nakulj I don't think venv supports having the virtual environment activated for child processes (e.g. tmux). It just happens to work, because the environment variables are exported to the child process.

You would have to activate the venv inside the tmux session again. With the fix in #93858, this shoud work :)

Either way, check if the implementation of virtualenv supports what you want to do. If it does, consider making a PR with the fix (the venv implementation is based on virtualenv).

@nakulj
Copy link
Author

nakulj commented Apr 11, 2023

Thanks! That makes sense. I just confirmed that the same 'bug' happens with virtualenv.

I tried writing a fix anyway, please take a look! :)

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

No branches or pull requests

3 participants