27

From inside a Debian docker container running jessie I get

vi blah
bash: vi: command not found

so naturally I reach for my install command

sudo apt-get install vim

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vim

while searching for some traction I came across these suggestions with various outputs

        cat /etc/apt/sources.list
deb http://deb.debian.org/debian jessie main
deb http://deb.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main

        apt-get install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package software-properties-common

        apt-get install python-software-properties
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-software-properties


        apt-get install apt-file
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package apt-file

since this server is the docker container for a mongo image it intentionally is a bare bones Debian installation ... installing vi is just to play about during development

61

I found this solution

apt-get update

apt-get install apt-file

apt-file update

apt-get install vim     # now finally this will work !!!

here is a copy N paste version of above

apt-get update && apt-get install apt-file -y && apt-file update && apt-get install vim -y
| improve this answer | |
  • 3
    Perfect.. just followed these steps blindly.. it worked.. – raksja Mar 10 '17 at 21:03
  • 1
    last line save my time thanks ... this is for second time ... that this answer helped me – saber tabatabaee yazdi Jul 4 '19 at 15:18
  • 1
    This worked great for me. All I had to do was apt-get update then apt-get install ... – Jeff Whiting Sep 6 '19 at 15:12
14

Although Scott Stensland's answer works, you don't need to install software-properties-common and python-software-properties. Running only the following commands is enough.

apt-get update
apt-get install apt-file
apt-file update
apt-get install vim
| improve this answer | |
  • this one works for me.. – Arman Ortega Jun 3 '17 at 15:12
  • this one works as well and don't install all the things that software-properties-common and python-software-properties will bring. – TheVillageIdiot Nov 25 '17 at 23:09
  • I get a Unable to locate package apt-file with this one :( – Stefan Haberl Jan 30 at 10:02

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