How to clean up ROS paths

asked 2023-04-20 11:29:52 -0600

AndyZe gravatar image

Somehow ROS2 humble and rolling got mixed up in my environment variables, like this:

PATH=/usr/lib/ccache:/home/andy/ws_ros2/install/moveit_core/bin:/opt/ros/humble/bin:/opt/ros/rolling/bin:/home/andy/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

Note that there is both :/opt/ros/humble/bin and :/opt/ros/rolling/bin. I think this came from sourcing Rollling, then sourcing Humble.

Is there an easy way to clean this up? What I've been doing so far to unset humble is:

printenv | grep -i humble ... to see a list of environment variables

export MY_ENV_VARIABLE= .... reset an environment variable with references to humble removed

But this takes awhile.

edit retag flag offensive close merge delete

Comments

Did you build your workspace with both sourced? If so, reset your bashrc to just source /opt/ros/rolling and then do a rebuild of your workspace.

pcoenen gravatar image pcoenen  ( 2023-04-21 10:30:02 -0600 )edit
  • "Did you build your workspace with both sourced?"

    I sourced one, built, then sourced the other, opened a new terminal, then tried to build.

  • "reset your bashrc to just source /opt/ros/rolling and then do a rebuild of your workspace."

    Hmm, I'm pretty sure I tried that. Should PATH get reset every time I open a new terminal?

AndyZe gravatar image AndyZe  ( 2023-04-21 10:35:51 -0600 )edit
  • I sourced one, built, then sourced the other, opened a new terminal, then tried to build.

Building leaves residue in the build and install directories, so sourcing them also brings the old /opt/ros stuff with it. Sourcing your humble workspace and then /opt/ros/rolling should result in workspace, humble and rolling on PATH. (at least that's my experience with ROS1)

  • Should PATH get reset every time I open a new terminal?

It does for me. Unless your path stuff comes from somewhere other than bashrc.

pcoenen gravatar image pcoenen  ( 2023-04-21 11:02:21 -0600 )edit