-
Notifications
You must be signed in to change notification settings - Fork 340
Don't infer cwd from workspace folder when there's an explicit program #4197
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
Conversation
Always use folder, since defaultCwd could also be relative.
helin24
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the problem we were having! Thanks!
|
Did you tests the change with opened workspace? If i remove the program it runs perfectly now. |
|
@maik-kluwe can you provide more details about your exact setup? What do you mean by "opened workspace"? Do you mean a If the config above is inside the {
"folders": [{
"path": "/Users/danny/Desktop/dart_sample"
}, {
"path": "/Users/danny/Desktop/dart_sample_2"
}],
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Dart",
"type": "dart",
"request": "launch",
"program": "bin/main.dart" // Is this path relatve to dart_sample or dart_sample_2 ?
}
]
}
}Although this worked before, it was using the current open file which is not guaranteed to be correct (if you opened a file from another workspace folder and pressed Run, it will behave differently, and it's not clear that was expected). If you have launch configurations with relative paths in the workspace file, you should use variables to indicate which workspace folder they are relative to: https://code.visualstudio.com/docs/editor/variables-reference#_variables-scoped-per-workspace-folder For example: {
"folders": [{
"path": "/Users/danny/Desktop/dart_sample"
}, {
"path": "/Users/danny/Desktop/dart_sample_2"
}],
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Dart",
"type": "dart",
"request": "launch",
"program": "bin/main.dart",
"cwd": "${workspaceFolder:dart_sample_2}", // This uses the workspaceFolder path from dart_sample_2
}
]
}
}If you want it to run "whichever project the open file is in" then you should be able to use If this isn't the issue you are seeing, please file a new issue and include specific details that will help me reproduce. Thanks! |
|
Sorry about the missing information. In my case i have created a .code-workspace file with just the name and paths of the projects in it: In each of the Projects (in my case My assumption was that with this setup dart should know the location of the At the end: |
|
@maik-kluwe you are correct - if the launch config is inside the project folder, this should work - I'll take a look shortly. Thanks! |
|
I can repro this - have opened #4239 and will do some digging. Sorry for the bother! |
|
@maik-kluwe can you switch to the pre-release (v3.53.20221102) Dart extension and verify it fixes your problem? If so I'll push it out to the stable version: |
|
It works 👍 Thank you! |
|
Great, thanks for confirming! I'll push it out to stable shortly. |

@helin24 does this solve the issue you had?
If there's a
programwe will try to infer acwdfrom it, but if that fails, we should no longer use the workspace folder. We'll only use the workspace folder directly is there was no open file orprogram.Then, if we still don't have one (which we won't for a special
targetthat doesn't have an enclosingWorkspaceFolder) we'll look for a common ancestor for all workspace folders.