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

Integrated terminal does not auto source venv on start #98252

Closed
ianzur opened this issue May 20, 2020 · 3 comments
Closed

Integrated terminal does not auto source venv on start #98252

ianzur opened this issue May 20, 2020 · 3 comments
Assignees
Labels
terminal Integrated terminal issues

Comments

@ianzur
Copy link

ianzur commented May 20, 2020

  • VSCode Version: 1.45.1
  • OS Version: Debian 10 buster

This occurs the next time you open vscode if you leave the integrated terminal window open when exiting vscode.

Steps to Reproduce:

  1. create a new python project
mkdir vscode_bug_project
cd vscode_bug_project/
touch foo.py
  1. create a python virtual environment python3 -m venv env
  2. Set pythonPath variable for vscode
    • mkdir .vscode
    • nano .vscode/settings.json (set pythonPath as shown below)
{
        "python.pythonPath": "env/bin/python",
}
  1. code .
    • open integrated terminal ctrl+` (code correctly sources venv here!)
  2. Close vscode with integrated terminal open
  3. code .
    • integrated terminal is open but has not activated my virtual env

While the work around is easy enough (ctrl+d to close then ctrl+` to reopen integrated terminal which then automatically activates the venv). It is rather frustrating as my first error is a python2->3 syntax problem when starting development everyday, since I forget to close then reopen the integrated terminal or manually activate my venv.

Is there a variable that I can set to automatically kill the integrated terminal on exit?

Does this issue occur when all extensions are disabled?: Yes

@Tyriar
Copy link
Member

Tyriar commented Jun 8, 2020

The terminal is killed on exit? I suspect step 6 is launching a brand new VS Code which sources a new environment based on env so it's by design that the virtual env isn't covered. For better venv support you'd be better off installing the Python extension which will automatically run it for you when you open terminals.

@Tyriar Tyriar closed this as completed Jun 8, 2020
@ianzur
Copy link
Author

ianzur commented Jun 8, 2020

I don't know if the terminal is killed on exit. If I could set workbench.action.terminal.kill to be run when I close VS Code then I would consider this issue closed.

The Python extension is installed. The extension does correctly source the virtual environment when I open terminals, but sometimes the terminal is already open when I start VS Code and this open terminal has not sourced the virtual environment defined in the workspace settings.

The work around is easy enough (ctrl+d to close then ctrl+` to reopen integrated terminal which then automatically activates the venv), but currently I do not consider this issue closed.

@Tyriar
Copy link
Member

Tyriar commented Jun 9, 2020

but sometimes the terminal is already open when I start VS Code and this open terminal has not sourced the virtual environment defined in the workspace settings.

Ah it wasn't clear what you meant exactly. So this is kind of a feature of VS Code where we don't block the UI (or terminals) on the slow launching extension. There is a way to improve this that works even before the Python extension is loaded via a new API (stable in 1.46), but it's yet to be picked up by them. You should 👍 microsoft/vscode-python#11039 to add your vote as it will solve your problem.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
terminal Integrated terminal issues
Projects
None yet
Development

No branches or pull requests

3 participants
@Tyriar @ianzur and others