'I have installed both ROS 1 (neotic) and 2 (galactic) but package path is the same upon checking

I am new to ROS and I have been following the instructions from ROS wiki page. I installed both ROS 1 (neotic) and ROS 2 (galactic). I printed the environment information for each using: printenv | grep ROS

I first tried to source (does this mean initialize an environment?) ROS 1 (neotic) using the code:source /opt/ros/neotic/setup.bash

and the result is:

ROS_VERSION=1 ROS_PYTHON_VERSION=3 ROS_PACKAGE_PATH=/opt/ros/noetic/share ROSLISP_PACKAGE_DIRECTORIES= ROS_ETC_DIR=/opt/ros/noetic/etc/ros ROS_MASTER_URI=http://localhost:11311 ROS_LOCALHOST_ONLY=0 ROS_ROOT=/opt/ros/noetic/share/ros ROS_DISTRO=noetic

But when I source ROS 2 using the codesource /opt/ros/galactic/setup.bash and printed the environment information, the output is:

ROS_VERSION=1 ROS_PYTHON_VERSION=3 ROS_PACKAGE_PATH=/opt/ros/noetic/share ROSLISP_PACKAGE_DIRECTORIES= ROS_ETC_DIR=/opt/ros/noetic/etc/ros ROS_MASTER_URI=http://localhost:11311 ROS_LOCALHOST_ONLY=0 ROS_ROOT=/opt/ros/noetic/share/ros ROS_DISTRO=noetic

Can you enlighten me about this? It seems like the ouput is from the bash file but how can I make sure that ROS 1 would not mix up with ROS 2?

ros


Solution 1:[1]

I had the same problem but then I found out that I was using the same terminal to source foxy after sourcing noetic. Closing the terminal after sourcing a version of ROS then opening a new terminal and sourcing the second version solves the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ice_man