apt build-dep fails, unable to locate source package, despite deb-src lines present in the /etc/apt/sources.list.d folder

15,454

Solution 1

You need to uncomment the deb-src lines in the main sources file /etc/apt/sources.list, not the extra files in /etc/apt/sources.list.d

For example, change:

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted
#deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted

to

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted

Then update the local database:

sudo apt update

and proceed :)

Solution 2

software-properties-gtk option "Source code"

From the GUI, you can run:

software-properties-gtk

then under the "Ubuntu Software" tab click "Source code":

enter image description here

This has added some deb-src lines under /etc/apt/sources.list, and now I can do sudo apt-get build-dep <package>.

Tested on Ubuntu 16.04 to 18.04.

CLI method

sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update

Tested on the Ubuntu 18.04 Docker image. After this change, I can successful do for example:

sudo apt-get build-dep hello

and before the change it failed with the error:

E: You must put some 'source' URIs in your sources.list
Share:
15,454

Related videos on Youtube

Josh Pinto
Author by

Josh Pinto

Updated on September 18, 2022

Comments

  • Josh Pinto
    Josh Pinto over 1 year

    I ran sudo apt-get build-dep emacs24 and it returned the error:

    Reading package lists... Done
    E: Unable to find a source package for emacs24
    

    Now I know the usual advice in this situation, that is, uncomment deb-src lines in the .list files in your /etc/apt/sources.list.d folder (per https://unix.stackexchange.com/questions/158395/apt-get-build-dep-is-unable-to-find-a-source-package). I've tried this though! Every single file in my /etc/apt/sources.list.d folder has any deb-src lines in it uncommented. I even ran sudo apt-get update after uncommenting these lines! So please help me. Here are the contents of my /etc/apt/sources.list.d folder, if you need the contents of any of these files, just say and I'll be happy to provide them.

    $ ls /etc/apt/sources.list.d
    alexlarsson-ubuntu-flatpak-xenial.list
    alexlarsson-ubuntu-flatpak-xenial.list.save
    cpick-ubuntu-hub-xenial.list
    cpick-ubuntu-hub-xenial.list.save
    damien-moore-ubuntu-codeblocks-stable-xenial.list
    damien-moore-ubuntu-codeblocks-stable-xenial.list.save
    danielrichter2007-ubuntu-grub-customizer-xenial.list
    danielrichter2007-ubuntu-grub-customizer-xenial.list.save
    docker.list
    docker.list.save
    dolik-rce-ubuntu-upp-xenial.list
    dolik-rce-ubuntu-upp-xenial.list.save
    dotnetdev.list
    dotnetdev.list.save
    gnome3-team-ubuntu-gnome3-staging-xenial.list
    gnome3-team-ubuntu-gnome3-staging-xenial.list.save
    gnome3-team-ubuntu-gnome3-xenial.list
    gnome3-team-ubuntu-gnome3-xenial.list.save
    google-chrome.list
    google-chrome.list.save
    google-earth.list
    google-earth.list.save
    icons.list
    icons.list.save
    jonathonf-ubuntu-golang-xenial.list
    jonathonf-ubuntu-golang-xenial.list.save
    kubuntu-ppa-ubuntu-backports-xenial.list
    kubuntu-ppa-ubuntu-backports-xenial.list.save
    mmk2410-ubuntu-eclipse-ide-java-xenial.list
    mmk2410-ubuntu-eclipse-ide-java-xenial.list.save
    mono-jenkins.list
    mono-jenkins.list.save
    mono-xamarin.list
    mono-xamarin.list.save
    nodesource.list
    nodesource.list.save
    noobslab-ubuntu-macbuntu-xenial.list
    noobslab-ubuntu-macbuntu-xenial.list.save
    notepadqq-team-ubuntu-notepadqq-xenial.list
    notepadqq-team-ubuntu-notepadqq-xenial.list.save
    runescape.list
    runescape.list.save
    saiarcot895-ubuntu-myppa-xenial.list
    saiarcot895-ubuntu-myppa-xenial.list.save
    spotify.list
    spotify.list.save
    trinity.list
    trinity.list.save
    ubuntu-elisp-ubuntu-ppa-xenial.list
    ubuntu-elisp-ubuntu-ppa-xenial.list.save
    unity8-desktop-session-team-ubuntu-unity8-preview-lxc-xenial.list
    wine-ubuntu-wine-builds-xenial.list
    wine-ubuntu-wine-builds-xenial.list.save
    

    If relevant, and you can't tell by the previous bits of information I provided, I am operating on Ubuntu 16.04.1.

  • jakar
    jakar over 5 years
    Not just for the lazy. This (or something similar) is necessary for a script or a Dockerfile.
  • iopq
    iopq about 4 years
    Don't forget to sudo apt update after. Seems obvious, but I forgot to do this
  • Zanna
    Zanna about 4 years
    thanks @iopq - I updated my answer to include that :)