Error :: You must put some 'source' URIs in your sources.list

Solution 1:

software-properties-gtk option "Source code"

I recommend this for the desktop:

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>.

I've couldn't find a clean CLI method so I create this bug report for it: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1802718

Tested on Ubuntu 16.04 to 18.04.

CLI method

I recommend this for Docker images:

sudo cp /etc/apt/sources.list /etc/apt/sources.list~
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 successfully 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

Previously mentioned at: https://askubuntu.com/a/1011675/52975 go and upvote that answer.

Note however that the /etc/apt/sources.list file contains lines such as:

# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

which means that the above sed would enable sources but not non-sources for some types of repos. I don't think that it matters much though.

Solution 2:

You can edit the source list (/etc/apt/sources.list) directly. I think you need to add in/uncomment these lines:

deb-src http://archive.ubuntu.com/ubuntu trusty main restricted #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty-updates restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse #Added by software-properties
deb-src http://security.ubuntu.com/ubuntu trusty-security restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty-proposed restricted main universe multiverse #Added by software-properties

I worked this out by disabling the source code option, and saving one copy of the sources.list file, then enabling the source code option, saving another copy, then running diff on both.

You may want to change the prefix http://gb. to the prefix of the other sources in your list (so it uses your nearest repo mirror), and you can also ignore the #Added by software-properties.

After editing sources.list, run sudo apt-get update before trying to install again.

The full diff can be found here


Another way is to generate a new one. One method to get a complete sources.list is to use this site:https://repogen.simplylinux.ch/