Home > OS >  Can't Read Environment Variable $HOME inside VSCode ROS Debugger
Can't Read Environment Variable $HOME inside VSCode ROS Debugger

Time:12-06

I have a very simple launch file such as shown below:

<launch>
  <arg name="dataset_dir" default="$(env HOME)/mnist" doc="location to the dataset" />
  <node name="listener" pkg="package_a" type="listener.py" output="screen"/>
  <node name="talker" pkg="package_a" type="talker" output="screen"/>
</launch>

While running inside VSCode ROS Debugger, it shows following error:

enter image description here

Please see the content of launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "ROS: Launch",
            "request": "launch",
            "target": "/home/ravi/catkin_ws/src/package_a/launch/bringup.launch",
            "type": "ros"
        }
    ]
}

The code works fine in normal terminal but shows error inside VSCode.

I am using VSCode v1.62.3 on ROS Melodic inside Ubuntu 18.04.6 LTS OS.

CodePudding user response:

This is being tracked under https://github.com/ms-iot/vscode-ros/issues/566. If you launch code from your terminal window, it will inherit environment variables. Or you can add an 'env' option to the launch configuration such as:

        {
            "name": "ROS: Launch",
            "request": "launch",
            "env": [
              "HOME": "/home/ravi"
            ]
            "target": "/home/ravi/catkin_ws/src/package_a/launch/bringup.launch",
            "type": "ros"
        }
  • Related