I am trying to install a program for my user because I don't have sudo privileges.

I tried to install dos2unix package as follows:

apt-get source dos2unix 
./configure --prefix=$HOME/myapps
make install

But I get the following error:

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

As I cannot edit sources.list, is there a way to make apt-get read another file?

  • 1
    Don't think you can, the only way to get apt to use a different source is to add a repo in /etc/apt/sources.list.d/, but for that you need to create a file in that folder and only root can do that. – Hunter.S.Thompson Jan 31 '18 at 11:16
  • @Hunter there is a way, see my answer ;-). – Stephen Kitt Jan 31 '18 at 13:20
  • It might be easier to apt-get download dos2unix; dpkg-deb -x dos2unix*.deb, but dependencies will be a problem either way – muru Jan 31 '18 at 14:21

You can use another sources.list, and as muru pointed out, it’s as simple as

apt -o "Dir::Etc::sourcelist=/path/to/your/sources.list" source dos2unix

The documentation suggests that this isn’t possible except in a configuration file, but it turns out the documentation is wrong (see the revision history for the configuration file variant).

Alternatively, you could clone the package source directly, if the package is maintained in a revision control system. apt showsrc dos2unix shows

Vcs-Git: https://anonscm.debian.org/git/collab-maint/dos2unix.git

so if you have git installed you can clone that. debcheckout, in the devscripts package, can automate that for you, but you probably don’t have that installed... See How to know the source repository of a package in debian? for details.

  • I learn something new here everyday! – Hunter.S.Thompson Jan 31 '18 at 13:22
  • Can't apt configuration options also be passed as command line options? A la askubuntu.com/a/698028/158442 – muru Jan 31 '18 at 14:14
  • Indeed @muru, I was trusting the documentation which says that the Dir::Etc options can’t be set on the command-line! – Stephen Kitt Jan 31 '18 at 14:16

EDIT: See Stephen Kitt's excellent answer. I'm not deleting this answer because although you asked 'How to make apt read a different sources.list", you seem to really just want to get a single source tarball for a one-time purpose, and for that its simplest to just perform a manual download.

PRIOR ANSWER apt-get is primarily a program for privileged users for system-wide maintenance. You want a solution for a non-privileged user to perform a local task.

There are several ways to manually get the sources:

1) Directly from the debian website by performing a web search for "debian package dos2unix". The link to the source tarball is on the right side of the page.

2) Directly from the developer. Run apt-cache show [package-name] and find the url for the developer homepage. In this particular case, this won't be helpful because the link is bad.

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.