Skip to content

workspaceFolder path added during debug shadows envFile #21257

Description

@BaconPancakes

Type: Bug

Behaviour

Expected vs. Actual

Expected: VSCode debugging prioritizes PYTHONPATH above stuff that was added on its own.

Actual: sys.path shows that workspaceFolder was added to the top, which shadows everything below.
This used to work before.

Steps to reproduce:

  1. Create an envFile with PYTHONPATH with some package lib. Maybe have a module foo.

  2. Open a new workspace with a folder lib, unrelated to the previous one. Set the envFile to what was created in 1. Make a pytest where you attempt to import lib.foo.

  3. Debug the test. ImportError, foo not found because lib.foo is shadowed by workspace lib. Can verify by setting a breakpoint and printing sys.path.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


envFile: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: false
• flake8Enabled: true

formatting
• provider: "black"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"

testing
• cwd: "<placeholder>"
• promptToConfigure: false
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Extension version: 2023.8.0
VS Code version: Code 1.78.2 (b3e4e68a0bc097f0ae7907b217c1119af9e03435, 2023-05-10T14:39:26.248Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: Yes
Remote OS version: Linux x64 5.15.0-71-generic
Connection to 'ssh-remote+7b22686f73744e616d65223a224c6f63616c2d5562756e74752d426f78227d' could not be established
Remote OS version: Linux x64 5.15.0-71-generic

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
282f8724:30602487
pyind779:30671433
f6dab269:30613381
pythonsymbol12:30671437
a9j8j154:30646983
showlangstatbar:30737416
vsctsb:30705553
azdwalk:30721579
pythonms35:30701012
pythonfmttext:30731395
pythoncmv:30739700
fixhidewlkth:30730051
hidesbindicator:30730055
pythongtdpathcf:30739705

Metadata

Metadata

Assignees

Labels

info-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions