ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Help With ROS2 Installation Locations (Ubuntu 20.04)

asked 2021-09-26 07:40:51 -0500

gr1p_coding gravatar image

I've got everything installed and working decently and am underway, but one thing that isn't quite clear is where the ROS installation is supposed to be located.

Following the install tutorial (, I downloaded the tarball and extracted it to ROS2 in the home directory: ~/ros2_foxy. I sourced the setup file and everything worked fine.

Later on I was going through a Nav2 tutorial ( about URDF which required installations of joint state publisher and xacro. When I ran the apt commands to install these, they got placed in /opt/ros/foxy, not the home location mentioned previously. So when trying to run it was complaining about not finding these newly installed packages. I changed .bashrc to source in /opt/ros/foxy/setup.bash instead and got it working. I'm just not sure that's the best permanent fix as there seems to be some items in ~/ros2_foxy that are still needed and not present in /opt/ros/foxy.

So the question is what is the difference between these two ROS install locations? Do you need both or one or the other? If ~/ros2_foxy is indeed the preferred location, how do I install new packages like joint state publisher or xacro into this directory rather than /opt/ros/foxy?

Thanks for the help, -Gavin

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2021-09-26 08:07:09 -0500

gvdhoorn gravatar image

If you're running Ubuntu -- and an Ubuntu version supported by the buildfarm / the ROS 2 version you're looking to use: use apt to install ROS. Unless you have a specific reason to do so, the binary archives ("fat archive" or "tarball") is not going to be the most convenient way to install ROS 2 on Ubuntu.

For apt based installs, everything will be in /opt/ros. The archive you downloaded can go 'anywhere', that's up to you.

Mixing-and-matching those two (or even three: if you'd include a from-source installation as well) is not a good idea -- and certainly not recommended.

The Nav2 tutorials essentially assume you've used apt to install ROS, hence the commands shown to you to install additional packages.

My advice would be to use apt and remove what you have in $HOME/ros2_foxy (unless you have a reason for using the archive-based install you haven't told us).

edit flag offensive delete link more

answered 2021-09-27 03:29:58 -0500

BrettRD gravatar image

updated 2021-09-27 03:34:23 -0500

If you can get any packages from binary (using apt), that's preferred.

If you're developing anything, you'll want a ros2 workspace with anything you're working on or can't get binaries of.

source /opt/ros/<your ros distro>/setup.bash (like you've don via bashrc) tells ROS where to find binary packages

source install/setup.bash tells ROS where to find your freshly built source packages

rosdep will help you track down any further missing dependencies, and will default to installing ROS packages with apt.

You shouldn't ever need to change anything under /opt/ros/, except via apt or rosdep.

developing with mixed source and binary is normal.

edit flag offensive delete link more


developing with mixed source and binary is normal

it is, once you get a bit more comfortable with things.

From the way the OP phrased his question, I get the impression he is just starting out.

In those situations, having a mixed-source base ROS 2 installation seems like something you should avoid, as it will typically just create more opportunities to get confused.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-27 04:14:39 -0500 )edit

answered 2021-09-27 05:24:46 -0500

gr1p_coding gravatar image

updated 2021-09-27 05:25:58 -0500

Thanks for the detailed replies. I got it all cleaned up and running smoothly now.

I did have some trouble manually deleting the ROS installations and trying to start again with apt because apt thought some things were still installed and skipped them. I'm sure there's a smarter way I could have gone about all this, but I ended up recursively running "sudo dpkg --remove --force-remove-reinstreq package_name" on all the ros-foxy packages listed in /var/lib/dpkg/info. Then I could start again with "sudo apt install ros-foxy-desktop" and all is well so far.

The understanding helps thought so thanks again. I read through the installation documentation in more detail and it talks about this and I just missed it...

edit flag offensive delete link more

Question Tools


Asked: 2021-09-26 07:40:51 -0500

Seen: 3,407 times

Last updated: Sep 27 '21