7

I am trying to install ROS Melodic on Ubuntu 20.04 using these commands

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full

But I get this error

E: Unable to locate package ros-melodic-desktop-full

I have tried to install the different versions and Kinetic Kame but they all give me the same error.

Jimmy202020
  • 71
  • 1
  • 1
  • 2
  • 1
    Ros Noetic was made for Ubuntu 20. Melodic is for Ubuntu 18 – Stigma May 23 '20 at 21:22
  • Ros Noetic wasn't out yet, at time of answer; I'm not sure if the website was updated at the time, or I was just blind. But it's out now! – JWCS May 26 '20 at 22:09

3 Answers3

12

In your case, this won't work. There is no ROS version for Ubuntu 20, and Melodic is only found on Ubuntu 18. I recommend installing Ubuntu 18 if you have the choice.

ROS has a strict versioning scheme that aligns with different versions of Ubuntu. Ex:

  • Ubuntu 14 (aka Trusty) == ROS Indigo
  • Ubuntu 16 (aka Xenial) == ROS Kinetic
  • Ubuntu 18 (aka Bionic) == ROS Melodic
  • Ubuntu 20 (aka Focal) == ROS Noetic
  • Ubuntu 22 (N/A)

(You can still, like, manually compile ROS, but I'd recommend against it for sanity's sake. Less things to go wrong)

EDIT!

I originally wrote this on May 22, 2020, not realizing that ROS Noetic was going to be released on May 23, 2020. It should have full official apt support, just like the rest of the ROS versions. If you're set on using Ubuntu 20 vs 18, Noetic installed via apt is now the official way to go!

JWCS
  • 1,120
  • 1
  • 7
  • 17
  • What about installing a newer version (Noetic) into `Ubuntu 18.04 LTS` ? Is changing the `lsb_release -sc`enough, or would it cause some versioning or package problems? – M.K Sep 02 '22 at 14:09
3

Replace the first command

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

by

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu bionic main" > /etc/apt/sources.list.d/ros-latest.list'

# or equivalently

sudo echo "deb http://packages.ros.org/ros/ubuntu bionic main" >> /etc/apt/sources.list.d/ros-latest.list

The installation would start.

This is because the lsb_release -sc command is sending focal (Ubuntu 20.xx) argument to the echo command, while it should be bionic (Ubuntu 18.xx), and thus, the repositories for noetic are added instead of melodic.

Himanshu Tanwar
  • 198
  • 1
  • 11
  • 1
    True! This is also an especially good point if you're not using vanilla Ubuntu, but a Ubuntu derivative, such as Linux Mint (my preference...). In those cases, likewise, `lsb_release -sc` would also give the wrong name, when you really need `xenial` / `bionic` / `focal`. – JWCS Feb 08 '21 at 19:23
2

Following the answer of JWCS and Himanshu Tanwar, just want to mention that if you are working on Debian, on Debian 10(buster) you'd better use Noetic. Using melodic on Buster will enter the same difficulty

This difficulty can be solved using a similar approach to the one in Himanshu Tanwar's answer, that is, change buster in "/etc/apt/sources.list.d/ros-latest.list" to bionic.

I was installing ROS on Raspbian which is based on Buster and had this problem.

Jianing
  • 168
  • 1
  • 8