-
Notifications
You must be signed in to change notification settings - Fork 31.6k
${workspaceFolder} variable not replaced when debugging Python #43303
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
Comments
Thank you for reporting this! I thought I was crazy, wondering what I'd accidentally changed somewhere to make things stop working. +1 to ${workspaceFolder} disappearing when debugging |
@agelter for the moment, please modify the setting |
I met the same problem. |
same problem |
It seems to not be limited to the I tried setting the path using |
Same problem, have to hardcode the pythonPath setting with an absolute path to make it work. No issue in 1.19 |
I just updated to 1.20.0 and hit the same problem, but in case this helps at all, I had a similar experience as @shaofuzhang It was not finding python when pythonPath was set to "${config:pythonPath}" in launch.json Seemed more like global settings were what was not coming across. |
Since variables like If the setting
the value of In order to resolve this, another substitution pass is necessary. Since you are seeing a regression here, it looks like VS Code did more than one substitution pass previously and in the latest version the second pass is now missing. So not the general variable substitution is broken, but the multi-pass substitution behavior. I don't like this (non documented) multi-pass behaviour, but if we did it in previous versions we have to continue doing it. @isidorn Is this analysis correct? |
@weinand That's how I interpret the issue, yes. Frankly, I'm not the biggest fan of the double-sub pass behavior either. Any way you can think of that allows for scoping |
@DonJayamanne why do you require double pass substitution? I suggest that we restore the previous behaviour for this milestone but phase it out in the future. |
These are totally valid. When debugging, the purpose of having
I fail to understand the logic behind this. If it's to be phased out do we have a solution that we could implement to work around this? I can think of a long-winded solution (debugger passing custom messages and these getting intercepted by the extension). But then it gets complicated with multi-root workspaces. |
Python is using variable syntax in the settings file, but it is relying on the fact that there is currently no general variable substitution available for settings. As a lucky consequence the variable syntax appears unmodified in the settings value. If VS Code would add variable substitution for settings in the future, use of
No, referencing workspace settings from within launch.json is not lost. In your case you are not only referencing a setting from the launch config (which is perfectly fine), but you expect that in the resulting value variables are substituted another time (and if this substitution results in more variables, then they are substituted again... ad infinitum). I think we have two (future) options:
|
Yes you're right, I have my own code in the extension to perform this substitution. |
If the Python extension is the only one using this capability, then I guess its up-to us (Python extension) to fix this at our end. The solution I propose is simple, the adapter makes a request to the extension layer (via a custom event) to perform the translation. The extension replies back via a custom request message. Note elegant, however based on the current API I don't see any other way around this. Feels wrong for the debug adapter to send requests to the extension in this manner, through an event and for the extension to send responses through requests!! Unfortunately the above solution will not work in multi-root workspaces. |
@weinand yes your analysis is correct. We used to perform multi pass substitution. Since this was nowhere documented and implemented in a strange way I decided to remove it when refactoring the I propose the following fix. In the python extension you can implement resolving configurations via this API. That basically means that before each debug start your extension will get to additionaly "massage" a configration. You will also get passed a Closing this as there is no action needed on the vscode side. @DonJayamanne for the future it would be great if you self host on vscode insiders so we catch changes like this earlier. This was pushed 3 weeks ago. |
@isidorn Yep, that's the right approach. @DonJayamanne in the Python extension's resolveDebugConfiguration(folder: WorkspaceFolder | undefined, config: DebugConfiguration, ...): ProviderResult<DebugConfiguration> {
// if 'pythonPath' attribute is missing
if (!config.pythonPath) {
config.pythonPath = ... // get pythonPath value from python settings
}
return config;
} In this case the In general we recommend to simplify launch configs by making most attributes optional and filling in missing values in the |
Thanks guys, will make the necessary fix at our end.
We did test and almost always test on the insiders, unfortunately it so happened that we weren't using relative paths (python installed somewhere in the workspace Folder) when testing.
Agreed |
Thanks, I think we can manage. |
Hi, I used to have this in my User settings (because I always use the same launch settings for all my projects/workspaces, so I don't want to have to copy and paste a launch.json file in all of them) This used to work fine until 1.20. "launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Python3",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "/Users/nicolas/anaconda3/envs/py3/bin/python",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python2",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "/Users/nicolas/anaconda3/envs/py2/bin/python",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
}
]
}
}
But it doesn't work anymore. It seems like it's related to the issues discussed here but even specifying the full path to my python executable doesn't work Is there a way to specify global python launch configurations in VSCode 1.20 ? |
Will this issue be updated when the fix is released? In my case I use {env:HOME} in workspace settings as a low rent way to enforce that developers on my team are installing anaconda locally on their machine and following the proscribed development environment setup process — and this is currently broken ... |
@breathe |
@isidorn Anything to verify here? |
@sandy081 this is an issue with the extension, removed the bug label |
Issue Type
Bug
This used to work in the previous version.
microsoft/vscode-python#691
#42787
Description
${workspaceFolder}
is no longer getting replaced with the valid value when debugging.Steps to reproduce:
one.py
with a print statementprint(1)
virtualenv
as follows:virtualenv .env
(instructions to install
virtualenv
can be found here)Python: Select Interpreter
(or click on the bottom status bar to bring up the list).env/bin/python
${workspaceFolder}
hasn't been replaced when debugging (notice how the setting in settings.json is referenced in launch.json).VS Code Info
VS Code version: Code 1.20.0 (c63189d, 2018-02-07T17:02:34.244Z)
OS version: Darwin x64 17.4.0
System Info
Extensions (20)
The text was updated successfully, but these errors were encountered: