Is it already possible to perform the prelaunch task in the same terminal as in which the debugger is started? I am creating a ROS package, and I would like to source the devel/setup.bash file before debugging my python node. I currently created the following launch.json and 'tasks.json` files:
Launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Experimental: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"preLaunchTask": "prerun"
},
]
Tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "prerun",
"type": "shell",
"command": "source devel/setup.bash"
}
]
}
I'm not 100% sure if this feature request belongs on this repository or the python-extension repository. Feel free to correct me so I can move the issue.
Related questions
@isidorn, @weinand & @alexr00 I was wondering if you already have an update on the status of this feature request? This feature would be very useful for me in order to source a catkin workspace before the debugger is started.
This belongs in the vscode repository.
Currently it is not possible to start preLaunchTask and debug in the same terminal as far as I know. Though @weinand and @alexr00 can correct me here.
However this is a valid feature request thus adding that label and assinging to backlog.
@isidorn Thanks for the fast response and for accepting my feature request. As also stated by @sofu456 on this issue in the meantime people can achieve the desired behaviour by adding the following code to their .bashrc
# Source ros setup.bash if present
if [ -f '../devel/setup.bash' ]; then . "../devel/setup.bash";fi
@isidorn correct, this is currently not possible.
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
Please reopen.
@mickare Maybe @isidorn can revise whether this feature-request is worth re-opening (putting it on the development back-log) or that there is not enough demand for it.
I can reopen it but that does not increase the likelyhood that we do it...
@isidorn thanks for your response. By @mickare requesting it to be reopened I guess there is still support for this idea. I, therefore, think that reopening the issue till the vscodebot closes it again might be a good way to check for support.
Yes, please add support for this feature, it would be very useful
Voting in favour of this feature. I am trying to run vglrun bash as a pre-launch task.
Voting for this one!
+1
In my case, I set some environment variables in the preLaunchTask which should also be present in the shell that runs the debugger. So this feature would be really useful because I don't want to pollute .bashrc.
@christian-vorhemus You just have to give up and use "envFile" to set up your env vars. It is the only way.
I've wasted far too many hours trying to find another one that works consistently
Please add support for this feature, or at the very least provide a valid workaround. This is completely blocking me from debugging my program: I cannot put the script into bashrc, that would be harmful.
The feature asks for:
Is it already possible to perform the prelaunch task in the same terminal as in which the debugger is started?
This is impossible for the following reason:
when the prelaunchTask is run, no debugger has started and consequently no terminal has been selected (or created).
So the only valid feature request would be:
Run debugger in same terminal as the prelaunch task.
@rickstaa would this reversed logic still solve your problem?
In this case the problem is how to communicate the terminal used by the prelaunch task into the debug adapter that actually launches the debuggee in the terminal...
Today the task and debug subsystems manage the terminals they use independently.
A minimal implementation would require this:
RunInTerminal DAP request with a kind "integratedTerminal" is received from the debug adapter, the strategy to find a terminal will use the remembered "prelaunchtask" terminal. Only if there is none, it will create a new terminal.@isidorn does this make sense?
@alexr00 is it feasible to return an identification of a terminal that was used to run the "prelaunchtask"?
@weinard That's would indeed solve my problem. Thanks a lot for wrting it in a more clear form.
@weinand feasible? Yes. However, currently the task service (which debug uses to launch the prelaunchtask) has no knowledge of terminals. I am not a huge fan of giving the task service too much knowledge of terminals since that is a nice abstraction and allows the old process task system to still work (tasks v1). It also gives tasks the freedom to someday decide that tasks shouldn't run in an integrated terminal and should instead run somewhere else.
@weinand makes sense from the debug point of view if the ID of the terminal can be fetched from the taskService. Which @alexr00 already commented on.
I think the request should be rephrased. We want to use same terminal to do prelaunch task is that we want to use prelaunch task to do environment setup.
In short, what we need is a way to do environment setup before debugger starts conveniently.
So just throw away the original idea of use prelaunch task to do the environment setup. Give us the ability to run arbitrary code to setup environment is sufficient.
If I am going to launch a bash terminal, let me source a sh file.
If I am going to launch cmd, let me run a bat file.
If I am going to launch a powershell, let me run a ps1 file.
And this is what should happen in a same process.
I think env file is sufficiently convenient. But not that flexible if you want to change it constantly.
Most helpful comment
Voting for this one!