1

I removed a repo by deleting its file from /etc/yum.repos.d using rm -rf. Then I tried to install the same repo with dnf install but it is not showing up in /etc/yum.repos.d or when I run dnf repolist.

I assume there is a possibility that the package may still be memorized in dnf's cache so I've tried clearing the cache by typing

dnf clean expire-cache and even passing the --refresh option to dnf install but the repo still doesn't show.

How do I install a repository after removing it manually?

  • 1
    Exactly what did you try to dnf install? – Michael Hampton Jul 22 '18 at 19:30
0

It's unclear what repo you deleted and tried to reinstall with your dnf install ... command but we can only assume that you tried to do something like this:

$ sudo dnf install -y http://download1.rpmfusion.org/free/fedora/releases/28/Everything/x86_64/os/Packages/r/rpmfusion-free-release-28-1.noarch.rpm
Fedora 28 - x86_64                                                                                                                               411 kB/s |  60 MB     02:30
Last metadata expiration check: 0:00:00 ago on Mon 23 Jul 2018 02:06:48 AM UTC.
rpmfusion-free-release-28-1.noarch.rpm                                                                                                            40 kB/s |  20 kB     00:00
Dependencies resolved.
...
...
  Preparing        :                                                                                                                                                         1/1
  Installing       : rpmfusion-free-release-28-1.noarch                                                                                                                      1/1
  Verifying        : rpmfusion-free-release-28-1.noarch                                                                                                                      1/1

Installed:
  rpmfusion-free-release.noarch 28-1

Complete!

Then deleted the .repo file like this:

$ sudo rm /etc/yum.repos.d/rpmfusion-free-updates.repo

And then tried to do install again:

$ sudo dnf install -y http://download1.rpmfusion.org/free/fedora/releases/28/Everything/x86_64/os/Packages/r/rpmfusion-free-release-28-1.noarch.rpm
RPM Fusion for Fedora 28 - Free                                                                                                                  1.3 MB/s | 754 kB     00:00
Last metadata expiration check: 0:00:00 ago on Mon 23 Jul 2018 02:11:12 AM UTC.
rpmfusion-free-release-28-1.noarch.rpm                                                                                                            57 kB/s |  20 kB     00:00
Package rpmfusion-free-release-28-1.noarch is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!

Solution

To get things back into shape you need to do a reinstall of this RPM not a install.

$ sudo dnf reinstall -y http://download1.rpmfusion.org/free/fedora/releases/28/Everything/x86_64/os/Packages/r/rpmfusion-free-release-28-1.noarch.rpm
Last metadata expiration check: 0:03:11 ago on Mon 23 Jul 2018 02:11:12 AM UTC.
rpmfusion-free-release-28-1.noarch.rpm                                                                                                            44 kB/s |  20 kB     00:00
Dependencies resolved.
...
...
  Preparing        :                                                                                                                                                         1/1
  Reinstalling     : rpmfusion-free-release-28-1.noarch                                                                                                                      1/2
  Erasing          : rpmfusion-free-release-28-1.noarch                                                                                                                      2/2
  Verifying        : rpmfusion-free-release-28-1.noarch                                                                                                                      1/2
  Verifying        : rpmfusion-free-release-28-1.noarch                                                                                                                      2/2

Reinstalled:
  rpmfusion-free-release.noarch 28-1

Complete!

And if we confirm, the deleted .repo file is back:

$ ls -l /etc/yum.repos.d/rpmfusion-free-updates.repo
-rw-r--r--. 1 root root 1264 Apr 24 11:27 /etc/yum.repos.d/rpmfusion-free-updates.repo

Without the URL?

If you want, you can do this without even knowing the URL to the original RPM that was used to setup/install this repo.

Check for the name of the RPM:

$ rpm -qa|grep rpmfus
rpmfusion-free-release-28-1.noarch

Then do the dnf reinstall ... with just the RPM's name instead:

$ sudo dnf reinstall -y rpmfusion-free-release
Last metadata expiration check: 0:10:00 ago on Mon 23 Jul 2018 02:11:12 AM UTC.
Dependencies resolved.    
...
...
  Preparing        :                                                                                                                                                         1/1
  Reinstalling     : rpmfusion-free-release-28-1.noarch                                                                                                                      1/2
  Erasing          : rpmfusion-free-release-28-1.noarch                                                                                                                      2/2
  Verifying        : rpmfusion-free-release-28-1.noarch                                                                                                                      1/2
  Verifying        : rpmfusion-free-release-28-1.noarch                                                                                                                      2/2

Reinstalled:
  rpmfusion-free-release.noarch 28-1

Complete!

And check that the file's back:

$ ls -l /etc/yum.repos.d/rpmfusion-free-updates.repo
-rw-r--r--. 1 root root 1264 Apr 24 11:27 /etc/yum.repos.d/rpmfusion-free-updates.repo

What if I don't know the RPM's name?

If you're in the odd predicament that you cannot figure out or recall what RPM to use to reinstall you're still not completely out of luck.

You can see what file you deleted from your history command and then run this rpm command to learn what RPM provided it:

$ rpm -qf /etc/yum.repos.d/rpmfusion-free-updates.repo
rpmfusion-free-release-28-1.noarch

And then do the reinstall with the RPM's name as described above.

What if the RPM wasn't installed via DNF or YUM?

In your particular case it turns out that the RPM you mentioned: geogebra-classic-6.0.477.0-201807062103.i386.rpm, isn't an RPM that contains any YUM .repo files.

$ rpm -qpl geogebra-classic-6.0.477.0-201807062103.i386.rpm  | grep yum
$

In this scenario, neither dnf nor yum can provide any assistance because neither knows the URL to reinstall/download this RPM. This is because this RPM was likely originally merely downloaded and installed directly.

When an RPM is installed in this manner, dnf & yum are blinded to the URL and are merely installing whatever RPM you instruct them to do via the file that's on your local HDD.

Your only recourse in this scenario is to re-download the RPM in question and reinstall it manually using either dnf, yum or rpm.

References

  • This would have been a good answer but it didn't work. However I was able to add the repo manually by re-creating the .repo file, importing the gpgkey and then installing the package I needed. In case you may be curious, this is the repo link – MyWrathAcademia Jul 23 '18 at 12:11
  • @MyWrathAcademia - was this RPM installed to begin with? Was it present? If it was I'm not sure how this wouldn't have worked. It's how RPM/YUM/DNF work. – slm Jul 23 '18 at 13:03
  • @MyWrathAcademia - OK so I've investigated your issue further. The RPM you downloaded had no YUM .repo files so your original question of deleting these files doesn't hold up. This RPM is merely an application that was installed, but it was not installed using any .repo file via YUM, you merely downloaded this RPM and installed. In this scenario, dnf or yum cannot help, since your installation was done by bypassing either of these tools in the downloading of the RPM. – slm Jul 23 '18 at 14:57
  • @MyWrathAcademia - see updates, I've further addressed your scenario. – slm Jul 23 '18 at 15:03

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.