Open m-morozov-kw opened 4 months ago
I believe the Python Extension is responsible for selecting the python interpreter, transferring issue
as @bschnurr said, python extension
is responsible for python.defaultInterpreterPath
but that said, even if it is passed to us, pylance
won't be able to resolve those env vars
.
pylance
doesn't pick up any random env var for security reasons. we only support ${WorkspaceFolder}
, ${WorkspaceFolder:name}
, ${env:HOME}
, ${env:USERNAME}
, ${env:VIRTUAL_ENV}
, ~/...
@luabud do we have this info documented somewhere?
I think the problem is all related to interpreter selection, so not related to Pylance. How the Python extension handles environment variable support is documented here: https://code.visualstudio.com/docs/python/environments#_environment-variables
@heejaechang When you say Pylance supports${WorkspaceFolder}, ${WorkspaceFolder:name},
, etc, do you mean in the settings such as exclude and include?
@luabud we also support it for python.pythonpath
. basically anywhere we accept path, we support those and only those env variables.
you can take a look at this file - https://github.com/microsoft/pyrx/blob/main/packages/pylance-internal/src/server/common.ts - and search for expandPathVariables
and resolvePathWithEnvVariables
to see what settings support those.
Environment data
Code Snippet
My settings.json
Repro Steps
Expected behavior
Vscode shows the proper python interpreter(active venv) in bottom status bar from the respective directory - either comp-de or project2
Actual behavior
Vscode rememberers only the one python interpreter which I explicitly pick from the
Command palette -> Select python interpreter
. In logs you can find log with wrong python path - "2024-05-27 13:37:57.658 [info] Python interpreter path: ~/.virtualenvs/prefix-utilities-pip/bin/python". And correct one - "2024-05-27 13:37:56.565 [info] Default formatter is set to charliermarsh.ruff for workspace /Users/username/projects/company/comp-de".Logs
Thank you