To install ROS 2 Humble Hawksbill on Debian 12, follow this detailed step-by-step guide:
1. Add the ROS 2 Package Repository
a. Configure your sources list
Open a terminal and add the ROS 2 repository to your system’s sources list:
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
Note: Since Debian is not officially supported by ROS 2, you might need to replace
$(lsb_release -cs)with the equivalent Ubuntu codename for the target ROS 2 Humble distribution (e.g.,jammyfor Ubuntu 22.04).
b. Add the GPG key
Import the GPG key used to sign the ROS 2 packages:
sudo apt update
sudo apt install -y curl gnupg2 lsb-release
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | sudo tee /usr/share/keyrings/ros-archive-keyring.gpg > /dev/null
2. Install ROS 2 Humble
a. Update package index
Update your local package index to include the ROS 2 repository:
sudo apt update
b. Install ROS 2
Install the ROS 2 Humble desktop full package:
sudo apt install ros-humble-desktop
If you want a lighter installation, you can use one of the following commands instead:
- For the base packages:
sudo apt install ros-humble-ros-base - For specific tools or packages, list available ROS 2 packages:
apt search ros-humble
3. Set Up the Environment
a. Source the ROS 2 setup file
Add the ROS 2 setup script to your shell configuration file (.bashrc or .zshrc):
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc
If you use zsh, modify .zshrc:
echo "source /opt/ros/humble/setup.zsh" >> ~/.zshrc
source ~/.zshrc
b. Verify the installation
Check the ROS 2 version:
ros2 --version
4. Install Additional Tools (Optional)
a. ROS 2 Command Line Tools
Install development tools and utilities for building and debugging:
sudo apt install python3-colcon-common-extensions python3-rosdep python3-argcomplete
b. Initialize rosdep
Set up rosdep for managing dependencies:
sudo rosdep init
rosdep update
5. Test the Installation
a. Launch the ROS 2 demo
Run the talker and listener example to ensure ROS 2 is working:
- Open a terminal and start a talker:
ros2 run demo_nodes_cpp talker - Open another terminal and start a listener:
ros2 run demo_nodes_cpp listener
You should see messages being published by the talker and received by the listener.
6. Troubleshooting
- If
ros2commands are not recognized, check if ROS 2 is correctly sourced:source /opt/ros/humble/setup.bash - If any dependencies are missing, use
rosdepto install them:rosdep install --from-paths src --ignore-src -r -y
This should allow you to successfully install and configure ROS 2 Humble on Debian 12!
The error occurs because the ROS 2 Humble binaries are built for Ubuntu 22.04 (jammy), which relies on certain dependencies (like libpython3.10) that are not available in Debian 12 (bookworm) by default.
To resolve this issue, you can try the following approaches:
Option 1: Use Docker for ROS 2
Using Docker is the easiest and cleanest way to run ROS 2 on Debian 12 without dealing with compatibility issues.
Install Docker:
sudo apt update sudo apt install -y docker.io sudo usermod -aG docker $USERPull the ROS 2 Humble Docker image:
docker pull osrf/ros:humble-desktopRun the Docker container:
docker run -it --rm osrf/ros:humble-desktop
This method isolates ROS 2 from your system, ensuring all dependencies work seamlessly.
Option 2: Build ROS 2 Humble from Source
If you need ROS 2 natively installed, you can build it from source with the following steps:
1. Install Required Tools
sudo apt update
sudo apt install -y build-essential cmake git python3-colcon-common-extensions python3-rosdep python3-vcstool wget
2. Install ROS 2 Dependencies
sudo rosdep init
rosdep update
3. Clone the ROS 2 Humble Source Code
Create a workspace and clone the ROS 2 repositories:
mkdir -p ~/ros2_humble/src
cd ~/ros2_humble
wget https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos
vcs import src < ros2.repos
4. Resolve Dependencies
Install all required dependencies:
rosdep install --from-paths src --ignore-src --rosdistro humble -y --skip-keys "libpython3.10 libopencv-core4.5d libpcl-common1.12"
5. Build ROS 2
Build the workspace:
colcon build --symlink-install
6. Source the ROS 2 Setup
Add the setup script to your shell configuration:
echo "source ~/ros2_humble/install/setup.bash" >> ~/.bashrc
source ~/.bashrc
Option 3: Manually Add Missing Dependencies
Manually resolving dependency issues can be complex but may work in some cases:
Enable Debian Backports or Experimental Repositories:
sudo nano /etc/apt/sources.listAdd the following line:
deb http://deb.debian.org/debian bookworm-backports main contrib non-freeInstall
libpython3.10: Download the necessary package from Ubuntu'sjammyrepository and install it manually.Example:
wget http://archive.ubuntu.com/ubuntu/pool/main/p/python3.10/libpython3.10_3.10.6-1_amd64.deb sudo dpkg -i libpython3.10_3.10.6-1_amd64.debRepeat for Other Dependencies: Identify the missing dependencies and manually download and install them.
Recommendation
The most reliable option for running ROS 2 Humble on Debian 12 is using Docker. Building from source is feasible but requires more effort to resolve all dependency issues. Let me know if you'd like assistance with a specific approach!