27

On freshly installed from scratch (not an upgrade) Ubuntu 24.04 I get this error when I run

$ sudo apt-get build-dep -y vlc  
Reading package lists... Done
E: You must put some 'deb-src' URIs in your sources.list

Prior to 24.04 fix was to make edits to /etc/apt/sources.list, but now on 24.04:

$ cat /etc/apt/sources.list
# Ubuntu sources have moved to /etc/apt/sources.list.d/ubuntu.sources

here is new file on 24.04

$ cat /etc/apt/sources.list.d/ubuntu.sources 
Types: deb
URIs: http://us.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

How do I add deb-src to the new file /etc/apt/sources.list.d/ubuntu.sources?

1 Answers1

31

There is a new config file location with a new file format layout for 24.04 unlike previous Ubuntu releases

Add the below snippet to the new config file /etc/apt/sources.list.d/ubuntu.sources

Types: deb-src
URIs: http://us.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports noble-proposed
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

If you want to do this using a one line command:


sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources

final updated file will become

cat /etc/apt/sources.list.d/ubuntu.sources 

Types: deb deb-src URIs: http://us.archive.ubuntu.com/ubuntu/ Suites: noble noble-updates noble-backports noble-proposed Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb deb-src URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

then run

sudo apt update

__________ below is server only not your laptop _______________

NOTE if the machine is under control of cloud-init (ignore this for those viewers at home this pertains to some remote cloud Ubuntu VM not your home laptop) instead make a similar addition of deb-src to the template file as per

$ cat /etc/apt/sources.list.d/ubuntu.sources 
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
##
## If you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add supplemental sources in /etc/apt/sources.list.d
## c.) make changes to template file
##      /etc/cloud/templates/sources.list.ubuntu.deb822.tmpl
##

For sake of completeness below currently happens (as of 20250825) on a recently updated ubuntu server 24.04 ... so issue continues ... note this is a serve not laptop so using the ubuntu UI is not an option hence the terminal commands


root@koselig ~ # 
root@koselig ~ # apt-get build-dep -y vlc  
Reading package lists... Done
E: You must put some 'deb-src' URIs in your sources.list
root@koselig ~ # 
root@koselig ~ # cat /etc/apt/sources.list
# Ubuntu sources have moved to the /etc/apt/sources.list.d/ubuntu.sources
# file, which uses the deb822 format. Use deb822-formatted .sources files
# to manage package sources in the /etc/apt/sources.list.d/ directory.
# See the sources.list(5) manual page for details.
root@koselig ~ # 
root@koselig ~ #  cat /etc/apt/sources.list.d/ubuntu.sources 
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
##
## If you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add supplemental sources in /etc/apt/sources.list.d
## c.) make changes to template file
##      /etc/cloud/templates/sources.list.ubuntu.deb822.tmpl
##

See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to

newer versions of the distribution.

Ubuntu distribution repository

The following settings can be adjusted to configure which packages to use from Ubuntu.

Mirror your choices (except for URIs and Suites) in the security section below to

ensure timely security updates.

Types: Append deb-src to enable the fetching of source package.

URIs: A URL to the repository (you may add multiple URLs)

Suites: The following additional suites can be configured

<name>-updates - Major bug fix updates produced after the final release of the

distribution.

<name>-backports - software from this repository may not have been tested as

extensively as that contained in the main release, although it includes

newer versions of some applications which may provide useful features.

Also, please note that software in backports WILL NOT receive any review

or updates from the Ubuntu security team.

Components: Aside from main, the following components can be added to the list

restricted - Software that may not be under a free license, or protected by patents.

universe - Community maintained packages. Software in this repository receives maintenance

from volunteers in the Ubuntu community, or a 10 year security maintenance

commitment from Canonical when an Ubuntu Pro subscription is attached.

multiverse - Community maintained of restricted. Software from this repository is

ENTIRELY UNSUPPORTED by the Ubuntu team, and may not be under a free

licence. Please satisfy yourself as to your rights to use the software.

Also, please note that software in multiverse WILL NOT receive any

review or updates from the Ubuntu security team.

See the sources.list(5) manual page for further settings.

Types: deb URIs: https://mirror.hetzner.com/ubuntu/packages Suites: noble noble-updates noble-backports Components: main universe restricted multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Ubuntu security updates. Aside from URIs and Suites,

this should mirror your choices in the previous section.

Types: deb URIs: https://mirror.hetzner.com/ubuntu/security Suites: noble-security Components: main universe restricted multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

  • 3
    Thanks for looking that up for everyone :) Don't forget to run apt update afterwards so that the source indexes are downloaded. – user2909614 Apr 28 '24 at 15:06
  • 1
    Here is a one-liner for this in Ubuntu 24.04 LTS: sed -i 's/^Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources – Utkonos Apr 28 '24 at 21:30
  • @Utkonos have you actually run your proposed one liner on 24.04 ? it is not valid ... it is similar to a one liner which did work on 22.04 or earlier yet fails on 24.04 – John Scott Stensland Apr 29 '24 at 12:05
  • It works 100%. It came from my command history and I just tested it again because you asked: # sed -i 's/^Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources # grep Types /etc/apt/sources.list.d/ubuntu.sources ## Types: Append deb-src to enable the fetching of source package. Types: deb deb-src Types: deb deb-src – Utkonos Apr 30 '24 at 00:29
  • 1
    @Utkonos Wow you are correct ... post your solution as an answer and I will checkmark yours as THE more elegant solution ... good job ... sometimes reality is stranger than one can imagine – John Scott Stensland Apr 30 '24 at 13:19
  • No need to make a second answer. Hopefully the edit that I just made will be accepted by the moderators. – Utkonos May 01 '24 at 01:36
  • 2
    Might be worthwhile doing a match for end of line with $ like so; sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources to prevent the sed command doing substitutions if run more than once. – Douglas Kosovic May 15 '24 at 01:37
  • Is this documented anywhere officially? I can't believe one has to go through all this without any real help from apt itself. – bparker Aug 24 '25 at 21:56
  • @bparker I updated this answer with copy N paste which shows docs if needed – John Scott Stensland Aug 25 '25 at 20:17