-
Notifications
You must be signed in to change notification settings - Fork 96
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
[bug] ROS distro not sourced for tasks.json on humble #1272
Comments
Thank you for the report. I don't know if it is possible to support this scenario. VSCode extension model has hooks for various events, which allows code to extension code to execute. Tasks.json is handled by VSCode - but it doesn't (last I looked) provide a general pre-execution hook to allow an extension to modify the execution environment. Sourcing ROS and the overlay is one of the main reasons that the VSCode ROS extension has its own task execution for build and debug. For this scenario, you may be able to manually prefix the command with the environment script, or build your own script which sources the environments then runs colcon. |
How is launch.json supposed to work if it cannot source the local environment? |
The problem here is using Task.json; I don't believe there is a hook for the ROS extension in that codepath of VSCode to influence the task environment. We register a VSCode launch.json handler which is ROS aware - and is able to source the environment. The Task..json file is not used when you use the ROS mechanism, so the extension can control the environment. |
Two environments need sourcing causing two separate issues. The Humble environment isn't sourced in tasksThe first is A workaround as I already shared is to prepend all commands with The local workspace is not sourced for ROS launch in debuggerlaunchRegardless of whether you build through a task, or build using your terminal, the local workspace has the build binaries and environment setup located in the default Without this, ros2 will give an error as I shared earlier: And, you are unable to debug your code in VSCode with the build in GDB GUI with a These two problems are independent issues. Would you like me to create an issue for the 2nd one? The title of this ticket only applies to the 1st one. I'm happy to set up a debug build of vscode, or whatever else you need to help you solve these issues on Ubuntu. |
The VSCode ROS extension Provides a "ROS Create Terminal" Command which creates a new terminal with ROS sourced. VSCode does not give extensions a hook for providing environment through the normal UI. |
Hello, I'm not sure if you need more info, but it appears this bug is only present when SSH'ing from Windows. If I have direct access to the Linux computer, the launch task works fine, and colcon build tasks works fine with the workaround I posted. It would be desirable for SSH not to adversely impact this extension's functionality. |
@Ryanf55 That interesting - thanks for the note. It certainly narrows down where this could be going wrong. |
(Please add appropriate labels)
Plugin v0.9.6 pre-release
what is the bug
When I add a task to run colcon build, it does not source the ROS environment.
Repro steps
"ros.distro": "humble",
to .vscode/settings.json on the remote computerTasks: Run task
and selectcolconBuildDebug
expected behavior
Colcon build will be successful and first
source /opt/ros/humble/setup.bash
before running.additional context
Even if I add
source /opt/ros/humble/setup.bash
to my bashrc, it doesn't source.As a workaround, I could do modify the task command like so, but that is not documented:
"command": "source /opt/ros/humble/setup.bash && colcon build --symlink-install --mixin debug",
Then, the launch still fails because it's not sourcing the local ROS workspace before launch:
The text was updated successfully, but these errors were encountered: