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

Setting the PYTHONPATH with terminal.integrated.env.* does not affect test discovery or debugging #12085

Closed
lsorber opened this issue Jun 1, 2020 · 6 comments
Labels
area-terminal feature-request Request for new features or functionality

Comments

@lsorber
Copy link

lsorber commented Jun 1, 2020

Environment data

  • VS Code version: 1.45.1
  • Extension version: 2020.5.80290
  • OS and version: macOS 10.15.4
  • Python version: 3.8
  • Type of virtual environment used: conda
  • Jedi or Language Server? Language
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

That setting PYTHONPATH to include a src directory with terminal.integrated.env.* (see below) also affects (a) test discovery, and (b) interactive debugging in VS Code.

  "terminal.integrated.env.linux": {
    "PYTHONPATH": "${workspaceFolder}/src:${env:PYTHONPATH}"
  },
  "terminal.integrated.env.osx": {
    "PYTHONPATH": "${workspaceFolder}/src:${env:PYTHONPATH}"
  },
  "terminal.integrated.env.windows": {
    "PYTHONPATH": "${workspaceFolder}/src;${env:PYTHONPATH}"
  },

Actual behaviour

  • For test discovery: test discovery fails because packages in src cannot be imported.
  • For debugging: debugging also fails because packages in src cannot be imported.

Workarounds

Steps to reproduce:

Same steps to reproduce as in #11875, which is a related issue.

@lsorber lsorber added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Jun 1, 2020
@brettcannon brettcannon added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Jun 1, 2020
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jun 1, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jun 1, 2020
@brettcannon
Copy link
Member

For the debugging case, please make sure that "console": "integratedTerminal" is set for the debugging configuration in your launch.json.

As for test discovery, that doesn't run through the terminal, so those settings won't affect it. I have marked this as a feature request to have us pick up these settings and apply them when doing test discovery.

@lsorber
Copy link
Author

lsorber commented Jun 1, 2020

@brettcannon

With regards to the debugging case: isn't "console": "integratedTerminal" the default for "request": "test" in launch.json? I'd expect debugging to work out of the box without having to configure it to use the integrated terminal.

EDIT: Setting "console": "integratedTerminal" does indeed create a new Terminal for debugging, which addresses the problem. Would be nice if it were documented though!

@brettcannon
Copy link
Member

@lsorber if you're up for it you can open an issue at https://github.com/microsoft/vscode-docs about documenting this for the debugger.

@luabud
Copy link
Member

luabud commented Jul 8, 2020

Duplicate of #6544

@luabud luabud marked this as a duplicate of #6544 Jul 8, 2020
@luabud luabud closed this as completed Jul 8, 2020
@ghost ghost removed the needs decision label Jul 8, 2020
@luabud
Copy link
Member

luabud commented Jul 8, 2020

(not actually a duplicate but we'll include this into the spec for #6544)

@cpoptic
Copy link

cpoptic commented Apr 14, 2021

Note for those struggling with getting a 'git' is not recognized as an internal or external command error message:
in your User settings.json file, there is a terminal.integrated.env.windows setting.

This object lets you explicitly set environment variables that will be added to the VS Code process to be used by the terminal on Windows.

Generally leave this blank to let VS Code use your default ENV variables.

I discovered Git was not being detected within the VS Code integrated Cmd terminal.
After much searching and frustration and when I checked the settings.json file there was an errant "PATH": "" line in the dictionary

So it should simply be
"terminal.integrated.env.windows": { }

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants