Unit 02 · lesson

Add the ROS 2 Apt Repository

Ubuntu's normal package repositories do not automatically know where ROS 2 packages come from.

The pinned Jazzy documentation uses the ros2-apt-source package to configure the ROS repositories and signing information.

Step 1: ensure Universe is enabled

Run:

sudo apt install software-properties-common
sudo add-apt-repository universe

Then update:

sudo apt update

Step 2: install curl

The official procedure retrieves the current ros2-apt-source release package:

sudo apt update && sudo apt install curl -y

Step 3: retrieve the current apt-source package

The pinned source uses these commands:

export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F'"' '{print $4}')

curl -L -o /tmp/ros2-apt-source.deb \
  "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb"

sudo dpkg -i /tmp/ros2-apt-source.deb

Notice something important: the documentation is pinned, but the command intentionally asks GitHub for the latest apt-source package release. Do not replace that behavior with a hard-coded package version from this course.

Inspect what happened

After installation, run:

sudo apt update

You should see apt refresh its known package sources without repository/signature errors.

Diagnosis rule

If this step fails, do not jump ahead to sudo apt install ros-jazzy-desktop.

The dependency chain is:

repository configured

apt can discover ROS packages

ROS packages can be installed

Fix the first failed boundary.

Checkpoint

Write down:

  • the apt-source version the command selected;
  • whether dpkg completed successfully;
  • whether sudo apt update completed without ROS repository errors.