Building ROS2 from source locally (without root)

asked 2022-05-24 01:32:39 -0600

catch22 gravatar image

updated 2022-05-24 01:33:05 -0600

Is it possible to build ros2 from source without sudo?

One of the first steps is sudo rosdep init

edit retag flag offensive close merge delete

Comments

1

One of the first steps is sudo rosdep init

For this specifically, see #q317938 and #q263604.

Is it possible to build ros2 from source without sudo?

It's not impossible, but without being able to install dependencies, it's going to be a very manual process.

I'd recommend looking into containers, such as Docker, Singularity/Apptainer, LXC, etc.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-24 01:49:33 -0600 )edit

Other systems like YOCTO, manage to build without sudo, after a handful of basic system dependencies are installed. At some point in the build process yocto also just fetches dependencies but installs them locally into build folders without root access. Its not clear why just building the ROS middle-ware requires root.

catch22 gravatar image catch22  ( 2022-05-24 02:03:44 -0600 )edit

Because Yocto builds root FS completely from source, and has the infrastructure to do that, including recursive dependency resolution, fetch and build. The default installation procedure for ROS 2 is to use pre-built binary packages for your OS -- if those are available.

From-source builds should only be used if they are required.

Could you perhaps clarify what your use-case is?

meta-ros for instance can be used to build root FS using Yocto, but it's certainly not the first point-of-entry for (new) ROS 2 users.

From your terse description it's not clear (to me at least) what you're trying to do: build ROS 2 from source in a general 'user' context, or build it for deployment in a more embedded/commercial environment.

Those two are rather different.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-24 02:08:32 -0600 )edit

Thanks for the response gvdhoorn.

My deploy target will be a custom embedded device, for which I have the yocto-sdk (which is really just a toolchain and a basic root FS for the target). On my desktop, I figured I'd do a source build to figure out the build process, and the dependencies. Given this I'm not sure I can avoid doing source builds.

Having step one of the build process install a bunch of unknown stuff into root feels wrong. Can this step be skipped if I install the same tools locally? Thou I'm not sure how I would figure out what these might be.

Since ROS install things into my system how do I run different versions of ROS?

catch22 gravatar image catch22  ( 2022-05-24 02:52:11 -0600 )edit

This feels a bit like an xy-problem.

It seems you're already using Yocto, so would it not be an idea to investigate meta-ros before doing anything else?

There is a process for building from-source on desktop OS, but it'll be radically different from how meta-ros approaches this.

I'm not sure what you'd gain by going the build-on-desktop route first.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-24 02:54:58 -0600 )edit

The base embedded system is provided by a vendor, so I only have an SDK at the moment.

My hope is I can build ROS's libs and apps and dependencies without root access, and with minimal coupling to the host OS. If ROS needs a specific 3rd party library than it should build it independently of the host OS's version.

catch22 gravatar image catch22  ( 2022-05-24 17:44:05 -0600 )edit
2

Well, as I wrote, it's all possible, but not a workflow that's been automated or documented.

For automated from-source builds with (almost) no dependencies on the host OS, meta-ros is typically used, or superflore (for platforms like Gentoo and Arch).

For from-source builds on Debian and derivatives, and RHEL and derivatives, system dependencies are typically resolved using rosdep and installed using the platform's package manager.

For other systems (and the ones mentioned earlier), a fully contained installation can be achieved using conda/robostack. Technically, you could build all of that yourself as well in a Conda environment.

If ROS needs a specific 3rd party library than it should build it independently of the host OS's version.

this sounds like an opinion, not a technical requirement or best-practice.

Perhaps taking a look at how meta-ros does this and replicating it could help?

gvdhoorn gravatar image gvdhoorn  ( 2022-05-25 02:09:29 -0600 )edit

If I focus on the desktop/ubuntu install for the moment. I think with one small tweak to rosdep , it might we able to run without root. It just needs the ability to store and read it package list from a user folder not one owned by root in /etc.

It already has the simulation run option, so it can be run without root, but instead outputs the commands that the user is then expected to run with sudo.

This would then be similar to other non-distro installers like "rustup" or "ghcup" which do something similar.

catch22 gravatar image catch22  ( 2022-05-28 19:30:50 -0600 )edit