10

The following command worked fine on Ubuntu 15.10:

sudo apt-get build-dep emacs24

However, on Ubuntu 16.04 I get the following error when running it:

Reading package lists... Done
E: You must put some 'source' URIs in your sources.list

In 15.10 all lines (around 10 in number) with deb-src in /etc/apt/sources.list where uncommented, whereas in 16.04 the corresponding lines where commented out. For example, here are 4 lines from my current sources.list:

## Major bug fix updates produced after the final release of the
## distribution.
deb http://no.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://no.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

What is the reason for this change?

Next, I would like to avoid manually edit /etc/apt/sources.list each time I do a reinstallation of Ubuntu. How can this (uncommenting the deb-src lines) be done automatically?

  • The reason is probably that for most users it's useless time/bandwidth wasting to update the database of available source packages every time. From the GUI where you configure the used repositories, you can easily disable/enable (comment/uncomment) those lines. There are also some sed scripts around. – JanC Apr 23 '16 at 17:30
  • The python3-software-properties package might be useful to write a Python script too. – JanC Apr 23 '16 at 17:43
  • @JanC Thanks, I wrote my own script. See answer below. – Håkon Hægland Apr 23 '16 at 17:55
10

Open Software & Updates and enable "Source code".

  • 12
    Useless if your ubuntu is a server with just shell – Voitek Zylinski Sep 1 '16 at 9:26
10

I had this same issue on a server install of Ubuntu 16.04, so no GUI. All that I needed was a couple of sed commands.

sudo sed -i -- 's/#deb-src/deb-src/g' /etc/apt/sources.list && sudo sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list

Then sudo apt-get update and continue on.

2

Here is a (currently untested) Bash script that could be used to uncomment deb-src lines in sources.list :

tempdir=$(mktemp -d)
cd "$tempdir"
source_file=/etc/apt/sources.list
new_file=sources.list.new
perl -pE 's/^#\s+(deb-src)/$1/' "$source_file" > "$new_file"
sudo cp "$new_file" "$source_file"
sudo apt-get update

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.