Ubuntu – apt can’t install local deb package

aptdpkgpackage-management

I have two Ubuntu system and they are exactly the same.

I execute several apt-get install XXX on one system and I can get the relative deb packages at /var/cache/apt/archives/. Then I copy these deb files to the other system at /home/me/archives/ and execute apt-get install ./*.deb.

I thought it should install the deb packages locally but to my surprise, it still redownload all deb files. I don't know why.

There are three things weird:

  1. When I execute apt-get install ./*.deb, lots of messages show up:

    Note, selecting 'python-rospkg' instead of './python-rospkg_1.1.4-100_all.deb'
    Note, selecting 'python-serial' instead of './python-serial_3.0.1-1_all.deb'
    Note, selecting 'python-service-identity' instead of './python-service-identity_16.0.0-2_all.deb'
    Note, selecting 'python-setuptools' instead of './python-setuptools_20.7.0-1_all.deb'
    Note, selecting 'python-sip-dev' instead of './python-sip-dev_4.17+dfsg-1build1_amd64.deb'
    Note, selecting 'python-sip' instead of './python-sip_4.17+dfsg-1build1_amd64.deb'
    Note, selecting 'python-six' instead of './python-six_1.10.0-3_all.deb'
    
  2. I try to install one of the deb packages, for example, apt-get install libwebp-dev_0.4.4-1_amd64.deb, but I always get the error:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package libwebp-dev_0.4.4-1_amd64.deb
    E: Couldn't find any package by glob 'libwebp-dev_0.4.4-1_amd64.deb'
    E: Couldn't find any package by regex 'libwebp-dev_0.4.4-1_amd64.deb'
    
  3. I've also tried to use dpkg -i *.deb to install these local deb packages, but it produced the error about missing some packages, then I executed apt install -f to get the missing deb package from the Internet, but the missing packages coming from the Internet and the original local packages are exactly the same…

In a word, my system cannot install local deb packages as expected.

Best Answer

"apt-get" command cannot be used like you want. You may install with it only from repositories. But the correct way is to use "dpkg" or "apt" commands:

sudo dpkg -i package_name.deb

or

sudo apt install package_name.deb

Using the dpkg may broke the package dependencies, which do not resolve it automatically so you can use apt-get to resolve the issue:

sudo apt-get install -f
Related Question