4

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.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Yves
  • 1,238
  • 5
  • 18
  • 33
  • 3
    Possible duplicate of [How do I install a .deb file via the command line?](https://askubuntu.com/questions/40779/how-do-i-install-a-deb-file-via-the-command-line) – Olorin Apr 24 '18 at 10:57
  • AFAIK only new versions of `apt` support installing a deb file directly. Which version is this? – Olorin Apr 24 '18 at 10:57
  • @Olorin check my re-edition. – Yves Apr 24 '18 at 11:02
  • What does it mean when you say you "have no right to use `dpkg -i`"? If you have the rights to use `apt`, it doesn't make sense to not have rights to use `dpkg`. – Olorin Apr 24 '18 at 11:03
  • `apt` can install a local deb file as can `dpkg`. `apt-get` cannot and never was intended to (after all that was what `dpkg` was for). The **get** part of means it gets it (ie. downloads) – guiverc Apr 24 '18 at 11:05
  • @guiverc I think it shouldn't get them anymore because all packages are local. If I cut off the Internet, it will block because it can't get them anymore... So obviously it get them from the Internet again. – Yves Apr 24 '18 at 11:09
  • @Olorin Well, I tried to use `dpkg` too but it still doesn't work..... – Yves Apr 24 '18 at 13:16
  • 1
    You need to be *very* careful when copying packages out of your apt archives from one system to another. It's entirely possible the packages won't work on the other system because you don't have certain dependencies or certain library versions or because of a different architecture or a different OS version. You should only ever do what you did with copying the `.deb` files from your local apt archive as an absolute last resort. – Thomas Ward Apr 24 '18 at 19:30
  • Possible duplicate of [How can I install software or packages without Internet (offline)?](https://askubuntu.com/questions/974/how-can-i-install-software-or-packages-without-internet-offline) – muru Jul 05 '18 at 08:39

2 Answers2

3

"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
Stefan
  • 389
  • 2
  • 6
  • As I said, `sudo apt install package_name.deb` doesn't work, it gives me the error. – Yves Apr 24 '18 at 12:48
  • `sudo gdebi ./package_name.deb` : **gdebi** is the local package installer (since 2006), which will also download and install dependencies. – Knud Larsen Apr 24 '18 at 12:50
  • Also, I've tried 'sudo dpkg -i * && sudo apt install -f', this will produce the same deb packages at `/var/cache/apt/archives/`, and if I execute `apt install ./*.deb` for the new deb packages again, it will f**king download again! GOD, I'm dying now... – Yves Apr 24 '18 at 12:59
  • 1st comment: nowhere mentions "sudo apt install package_name" in your question. "apt" and "apt-get" are two different commands. 3rd. comment: download again the package in separate folder. Navigate to it. And execute "sudo dpkg -i package_name.deb" – Stefan Apr 24 '18 at 13:36
1

This problem comes here:

I executed several apt install XXX, which are about python module, such as python-numpy etc. I thought it would depend on python2.7 so python2.7 would be downloaded and installed automatically but I was wrong (maybe it's because python3.5 has been installed by default? I don't know exactly the reason). Meaning that I should execute one more command: apt install python2.7. Otherwise, apt install ./*deb will redownload all of packages again. Also, I don't know why but dpkg -i *.deb && apt install -f didn't install python2.7.

Anyway, after installing python2.7 and put its deb package with other packages together, I can install all of them locally with the command apt install ./*.deb.

Yves
  • 1,238
  • 5
  • 18
  • 33