25

I am trying to locally install an rpm package without using the internet. I tried the following:

sudo rpm -u kernel-devel-4.2.7-200.fc22.x86_64.rpm

and I got:

error: kernel-devel-4.2.7-200.fc22.x86_64.rpm: hdr blob(2060952): BAD, read returned 0
error: kernel-devel-4.2.7-200.fc22.x86_64.rpm cannot be installed

I also tried:

sudo dnf --disablerepo='*' install kernel-devel-4.2.7-200.fc22.x86_64.rpm

and it still seems to be using the internet, so I can't figure out if it works or not since the internet connection is really slow.

Is there a way to fix this?

kolonel
  • 351
  • 1
  • 3
  • 3

2 Answers2

43

sudo dnf install /path/to/package.rpm will act on the package in the given path.

ILMostro_7
  • 3,199
  • 1
  • 21
  • 27
  • 6
    When trying this on a LIVE cd, I have to add `--disablerepo=*` – Andy Mar 28 '18 at 16:36
  • @Andy, I'm not sure if that's something that has changed with recent versions of `dnf`, but I don't see why you wouldn't be able to install the package locally by explicitly providing the full path to the `rpm` file as suggested in the answer. – ILMostro_7 Mar 30 '18 at 04:14
  • I found out that in the end, you are right. What was happening for me, is that I was trying to install 10 RPMs, but I was accidentally missing one dependency. I had never run a dnf command online, so my yum cache was empty. Without --disablerepo, all I got was an error message failing to update the "Updates" repo. So I had no idea what the error was, but with the --disablerepo, I got a nice clear message that I was missing an package. – Andy Apr 03 '18 at 02:36
  • @Andy please accept the answer if it's correct. – ILMostro_7 May 24 '18 at 02:52
  • I've also seen `sudo dnf localinstall ` used. Any difference in behavior? – Freedom_Ben Oct 30 '19 at 19:09
  • 2
    I'll answer my own comment, `localinstall` is a deprecated alias for `install` : https://dnf.readthedocs.io/en/latest/command_ref.html – Freedom_Ben Oct 30 '19 at 19:10
  • @ILMostro_7, in my case the system does not have access to the repositories over the network and the installation hangs when updating the metadata. So `--disablerepo=*` skips updating the metadata and starts installing the local package right away. – SergA Dec 13 '22 at 12:28
1
sudo dnf localinstall kernel-devel-4.2.7-200.fc22.x86_64.rpm

This worked for me!