-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
pipeTransport.pipeArgs command variable replacement not working #89758
Comments
(Experimental duplicate detection) |
/duplicate of #85206. My understanding is that a new API lands in 1.42 that will enable debuggers to handle this situation properly. |
Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines. Happy Coding! |
@gjsjohnmurray Thank you for the info! If I understand this correctly, |
@davidruhmann yes that's my understanding too. Maybe check that project's issues to see if they're already aware of this, and open an issue if not. |
After more investigation, This issue is not a duplicate and should be reconsidered. Created PR #92697 |
I'm opening this issue to discuss an unresolved problem that remains even after the fix for #85206. The remaining problem: Today variable substitution is a two phase process:
If a variable is command-based (e.g. relying on some code running in an extension), the extension code has only access to the unresolved launch configuration, that means it does not see other already resolved variables. The reason for this behavior is isolation and independence from evaluation order. A consequence of this is that a launch configuration can not be considered a "sequential program", that is executed from top to bottom. I firmly believe, that this approach is a "good design" even if it has limitations. If I understand the PR #92697 from @davidruhmann correctly, then he wants to change variable substitution to this:
If a variable is command-based and has access to the (partially) resolved launch config, then its value becomes order dependent. This is a problem, because we cannot preserve the order of properties in a JSON because we are not passing a launch.json as a string but as a Javascript object. The order of attributes might deviate from the order a user sees in the JSON's source (e.g. the launch configuration). |
@weinand Good breakdown. You might want to update this comment. Just not to be lost, if at the end, the decision is to leave the behavior as is, I propose that we update the documentation to clarify how variables are resolved. Something like Issues with similar confusions that I think documentation would help prevent:
The struggle I am having is figuring out the mechanism by which this use case should be solved. Appreciate feedback on them. Here are some some ideas I have been thinking about:
I am still am a fan of the replacing as resolved approach. Thanks for reading through all this! When I get a moment, may update my PR or add a new PR with an Idea 2 implementation. |
As a side note, this is the same exact issue as #80219. I am the author of the My initial suggestion to resolve this was idea 2, but @weinand questionned it back then. This commit d545dc3 shows when I reverted it. It was slightly different though: @davidruhmann if your PR goes through and not mine, I had added a little more(not much, but still) tests than you, which could be ported back to your PR. @weinand I think either this issue or #80219 should be closed as duplicate. |
@scabana Appreciate your information! I remember seeing your issue when investigating, but missed the PR you had made. Your changes look nice, so if you want to add them back in for consideration that works for me. Most of my time for these tasks has to wait for the weekends, so I probably will not be able to make any changes till then. |
I'd rather complete the discussion on which solution to use before adding more time into a solution that would not be good enough to be considered. I also have time to implement a solution. Let's see what @weinand thinks about this. My issue was "forgotten"/put on hold for months even though there was an associated PR (I understant the number of issues/prs opened on this repo, I'm not frustrated by it). I'd like to get a solution validated before code is done. |
Thanks for providing input and PRs for the discussion. My current take on the issue is still what I said yesterday: Interleaving variable resolution with substitution and introducing a mechanism to specify the order (e.g. via PR #80220) addresses the problem of non-determinism, but the syntax and the need to specify an order looks a bit clumsy for my taste. But there is a bigger issue. The problem is that a JSONs is:
Introducing immediate substitution of variables after their resolution and introducing sequence numbers to control the order of variable tries to turn the data structure and its "macro" mechanism into a real sequential program. But this is the wrong message for users. If we are opening the floodgates, there will be a stream of feature requests to add more program features to launch.json and task.json. Most likely the first request will be one for initialising variables before the substitution takes place... Before we are giving in to this direction, we should really try harder to solve the issue with a different approach. E.g. if we have dependencies between variables that rely on extension code and we cannot express the sequential evaluation order of these variables in a JSON, then maybe we should consider to use (extension) code instead. An interesting observation is that the only issues we got for this problem originated from the "pipeTransport" construct introduced for the "coreclr" debugger. Could we find a replacement for the "pipeTransport" complexity that moves the dependencies into the extension instead of having it in the launch.json? |
Thanks for taking the time to elaborate. I do agree the suggested ordering syntax is not great. I also agree that this kind of feature opens the gate for much more complex scenarios. The one thing here I'm not so sure about is the With that said, I think the real discussion here is more about the expected usage around launch.json. In the current situation, I feel, it is expected to have a lof of configurations to satisfy the current scenario. For simpler scenarios, non-dependant substitutions is good enough. I would say that if we can't achieve dependant substitutions in vscode code base, the complexity of it should not be pushed into the extensions. The reason is that extension authors would most likely need to start looking into specific variable substitutions to know which one would run first and which one last. This would effectively bind extensions together and require way more work. Today, I don't see a way to elegantly enable this scenario without the requirement of knowing a list of commands to run first or last. I would just drop this request (and #80219). The problem with either approaches of execution order as in
Maybe a more elegant solution would be to support a complex json object in the substitution, something like |
@scabana the problem is not the the fact that the The problem is that the implementation of the With the current 2-pass implementation of variable substitution If If this is not possible (e.g. because the picker UI requires the values from the @WardenGnaw please chime in for your insights (since we are not yet planning to address the issue on the VS Code side). |
@weinand Just writing out the method I think you are proposing to make sure I understand. Instead of solving this on vscode, update omnisharp-vscode to no longer use the Example?
Use something like the |
ok, I undertand. Been a while since I investigated this issue. The challenge here would be to still give flexibility to the user. In this example, the pickRemoteProcess command works in a specific way, but you could think that a user would want to use another version of pickRemoteProcess that potentially comes from another extension. In this issue's scenario, it is intentional that pickRemoteProcess and vscode-docker.containers.select are not known by both extensions. Moving this deeper into the extensions would require the extensions to know that a specific command (or configured one?) would be needed to be invoked later in the pipeline. The scenario of hardcoding the container id and process id in the configuration is also valid (but I wouldn't recommend doing it). With all that being said, from my side, we are moving away from this requirement and moving towards remote vs code. Debugging remotely is way way faster (at least of .net). |
@davidruhmann yes, your example is exactly what I was thinking of. And I understand that that approach results in some loss of flexibility. But since the "pipeTransport"/"pickRemoteProcess" is the only use case where users are suffering from the limitations of the "macro-based" variable substitution mechanism, I think we could more easily fix the issue on the coreclr side than adding a new and somewhat questionable feature to VS Code's variable evaluation and substitution. @scabana you said
I was actually hoping that VSCode Remote could be an elegant solution that would make the problem disappear. |
@Helloimbob and I were discussing this issue in microsoft/vscode-cpptools#5103 (comment) Note: C/C++ extension and C# extension use the same pickRemoteProcess logic. With @Helloimbob's investigation, he replaced
Is there an issue with |
@WardenGnaw you can find my analysis of the problem above. This comment and this explains why we don't want to fix the issue with the submitted PRs. In comment I try to explain how to avoid the issue. |
Is it unreasonable to suggest that |
@Helloimbob this issue is about "the only problem" use case: one command variable depends on another command variable. Your suggestion would not solve the case that is discussed here. And then there are the two variable types |
@Helloimbob Are you proposing a change to behavior where the That would solve the I like this and I don't at the same time. It would be nice, but could also be confusing to those just looking at a configuration. |
@davidruhmann Yep that is what I'm proposing - you're right that it then isn't obvious that |
I have a similar situation and stumbled upon this trying to avoid hardcoding a k8s namespace for attaching debugger to .net core:
I thought I might be able to get around this setting |
So, trying to make sense of this... as of November 2020, is there any way to use the following as pipeArgs for pipeProgram "docker"?
I'm trying to write a launch configuration that can attach a debugger to a running container, but my container names are dynamically generated (I run my containers using Skaffold, so I can't control that). My config looks like this, but doesn't work:
The error in remote-attach output is:
Or is there any other way I can pass my container name to the debugger? (apart from manually editing the launch configuration every time I need to attach to a process in a container) I tried executing the following custom .bat file as the pipeProgram, but I errors indicating that "grep", "awk" and "xargs" are not recognizable commands. Not sure how the debugger tries to execute the code.
|
As explained above (see comment and comment) variable substitution is a two phase process for good reasons. A launch.json is a configuration mechanism and variable substitution is just a string based macro mechanism. If these limitations mean that dependent variables can not be used in launch config, then I suggest to move the "dependent variable logic" into real code (i.e. move it into code, e.g. the extension). See my comment above. @willemodendaal You might want to file a feature request against the C# extension. |
Thanks for clarifying @weinand |
Attempting to figure out why input and command replacements do not work for
launch.json
pipeTransport.pipeArgs
(used in omnisharp-csharp extension). My use case requiresomnisharp-vscode
extension. However, this involves the vscode variable replacement logic, so I am posting it here.1.41.1
(also tried insider1.42.0-insider
)Darwin x64 18.7.0
Steps to Reproduce:
launch.json
for remote debugging a csharp docker container. (e.g.vsdbg
)My Use Case Example (requires
vscode-docker
extension)vscode-docker.containers.select reference: microsoft/vscode-docker#1240
Another Example
Output
Does this issue occur when all extensions are disabled?: Not Sure.
The text was updated successfully, but these errors were encountered: