Ask Your Question

Trouble installing ROS2 alongside ROS1

asked 2020-04-25 01:56:33 -0600

I have ROS Melodic on my Ubuntu 18.04, I installed ROS2 Eloquent and I get the following mistake//warning:

r4t@R4T:~$ source /opt/ros/eloquent/setup.bash 
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.

Then I do eng |grep ROS as mentioned on another thread, and I get


I don't know if the environment is configured correctly since everything it's kind of pointing out to Melodic version

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-04-25 04:46:53 -0600

gvdhoorn gravatar image

It's likely you have source /opt/ros/melodic/setup.bash at the end of your .bashrc (which is added at the end of the Environment Setup section of the ROS 1 installation instructions).

With just a single ROS version installed, that will be convenient (as it prevents you from having to type source /opt/ros/melodic/setup.bash in every new terminal).

However, with multiple ROS versions installed (and this goes for both multiple ROS 1 and ROS 2 versions and a mix of those), it will cause issues such as the one you encountered.

I would recommend to remove the auto-source-ing from your .bashrc, and manually source the setup file of the ROS version you want to work with instead.

edit flag offensive delete link more


I've removed the .bashrc autocompletion and it still keeps on telling me that the distro was set to eloquent, I've even deleted eloquent from my computer and the same keeps occurring.

blancoys gravatar image blancoys  ( 2020-08-18 03:07:20 -0600 )edit

I've removed the .bashrc autocompletion [..]

Bash auto-completion is an integral part of the Ubuntu UX in the shell. I would not remove it.

If you've actually removed the source /opt/ros/melodic/setup.bash line, that should have helped.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-18 03:17:47 -0600 )edit

To make sourcing the right distro process easier for me, I've added

function sr1 {                                                                  
        source /opt/ros/melodic/setup.bash                                      

function sr2 {                                                                  
        source /opt/ros/eloquent/local_setup.bash

to my .bashrc file. Now I just need to sr1 to source melodic, and sr2 to source eloquent.

ChuiV gravatar image ChuiV  ( 2021-06-21 09:08:26 -0600 )edit

answered 2021-03-10 07:04:03 -0600

I had the same problem with Foxy and Neotic. To solve it;

  • Remove Neotic and Foxy source from bash
  • In Foxy worskspace install/setup.bash (line22) COLCON_CURRENT_PREFIX="/opt/ros/noetic" change noetic to foxy
  • Delete and reinstall neotic

sudo apt-get remove ros-noetic-*

  • Source the workspace correctly.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-04-25 01:56:33 -0600

Seen: 1,016 times

Last updated: Mar 10 '21