In our previous blog post, we pointed out that it is very easy to remove Arch Linux's package manager. (UPDATE: The blog post mentioned has been removed.) But what happens if you do, and what are the risks you are taking once you do so? Is there a way to reinstall pacman? Are you able to remove the package manager from other Arch-like distributions that use the same package manager? Are you risking borking your Linux System by uninstalling it?
Arch Linux runs fine without Pacman
I decided to try uninstalling pacman myself by installing Arch Linux in a virtual machine and removing it by itself. It is important to only remove that package though by running
sudo pacman -Rd --nodeps pacman if you are a normal user, and
pacman -Rd --nodeps pacman if you are in a superuser environment, or logged into as root. Running
sudo pacman -R pacman will fail because there are dependencies that depend on Pacman. ATTEMPTING TO REMOVE
sudo pacman -Rs pacman, or
sudo pacman -Rsc pacman WILL REMOVE ALL PACKAGES THROUGH DEPENDENCIES, AND YOU WILL BE LEFT WITH A BROKEN SYSTEM! The system will warn you that pacman is designated at a HoldPkg, where such packages require confirmation before removal. Once I made sure that the package manager was the only package I was removing, I consented to the removal, and it actually worked. Some breakage did occur in some areas, such as attempting to use an AUR helper to install packages, and some libraries will show up as missing because they were deleted, but you are pretty much left with a Arch System without a package manager.
I would, however, highly recommend against uninstalling Arch's Package Manager. Especially because Arch Linux is a rolling-release Linux Distribution, you are at risk of falling behind on updates unless you decide to update every package yourself, which can take an enormous amount of time and skill. You may also break your Linux system while trying to update every package yourself, as differentiating versions of system packages can prevent you from using the appropriate utilities to make the packages, or it might cause certain system programs to stop running correctly, resulting in a broken system. For these reasons, you may want to consider reinstalling pacman.
Reinstalling Pacman: Do It Right...
One thing I learned from trying to reinstall Arch's package manager is to make sure you absolutely know what you are doing, and how to do it. By not knowing enough about Linux's utilities, I was able to corrupt my system by attempting to move pacman back to the correct directories but accidentally "backing up" all of the other system files into other folders. Since I had no GUI installed, I was able to type the wrong commands into the terminal to cause these problems. It was pretty easy to download pacman from the Arch Package's Website and extract it to an appropriate folder, though.
This is not how I would recommend reinstalling pacman though, because you have the chance of breaking your system trying to do it this way. Even if you have the expertise to do so, you should still proceed with caution seeing as you could easily destroy your system, requiring a reinstall of the system using a Live CD. We recommend reading the following forum posts on the Arch Linux Forums to see what other people have done in order to repair their system. The Arch Linux Wiki also provides two specific methods to reinstalling pacman. Please be sure to read all of the instructions carefully before attempting to restore the package manager. The links are available below:
- Pacman Command Not Found - Arch Linux Forum
- Pacman Commands Not Working From Command Line - Arch Linux Forum
- Pacman Crashes During An Update - Arch Linux Wiki
- Manually Reinstalling Pacman - Arch Linux Wiki
Do Not Attempt This On Manjaro
Like Arch Linux, Manjaro will simply not allow you to simply uninstall pacman as you would think. Attempting to run
sudo pacman -R pacman will fail with
error: failed to prepare transaction (could not satisfy dependencies), listing a few important packages that YOU SHOULD NOT REMOVE, such as manjaro-system, mhwd, and even yay if you use AUR packages. Attempting to run
sudo pacman -Rs pacman will yield the same result, requiring the use of
sudo pacman -Rd --nodeps pacman to continue uninstalling this package without affecting the other ones. Once again, Manjaro will specify that this package is being held, requiring confirmation to remove it. When do you remove it, it will probably behave the same way Arch Linux behaved with no package manager and missing libraries. You will also have problems with Octopi and Pamac, seeing as they no longer have a backend to work with.
To reinstall Manjaro's Package Manager without a Live CD, you must download it from one of the Manjaro Repos, as downloading the one Arch uses could cause issues with other packages, being released on an entirely different release schedule, causing version dependency issues. To get a list of repos to download the correct file from, go to the Manjaro Repo List Website. Select the mirror closest to you, then click the branch that you are using (Usually Stable or x32-stable if you are using a 32-bit Operating System), core, amd64 (Normal) or i386 (x32), then scroll down to find the appropriate pacman package you need. You may also find it easily with your web browsers Find Tool, usually enabled by pressing CTRL+F or CMD+F. Once you download this package, installation is similar to how you would do it on Arch Linux, following the steps mentioned above.
Conclusion – Should You Remove Pacman?
If you know your way around Linux, and you have a machine you wouldn't mind breaking, then you are free to do as you please. However, I would highly recommend doing this in a Virtual Machine instead so that you can easily erase the experiment once you are done, allowing you to use your system as if nothing had happened. Learning to reinstall Pacman by yourself makes a great opportunity to learn more about what Arch Linux is and how it works. You could also learn how to get around Linux without a package manager, which can be quite difficult but would also teach you a lot of information about the system.
I would NOT recommend this experiment to people who are new to using Linux. Seeing as mistyping one command can destroy your entire system, it is a good idea to learn more about how Linux works before even trying this. This experiment is for people who are advanced users. Other package managers, such as the Advanced Packaging Tool, put in heavier safeguards for removing themselves for good reasons. Feel free to come back once you know more about the inner workings.
Please let us know in the comments whether you want to see what happens when you try this on other distributions such as Debian and Ubuntu, and feel free to request your own experiment down there as well. If you liked the post, please give us a favorite, and stay tuned for more Linux experiments in the future. Also feel free to take a look at some of the other content we produce, such as the three hardest distributions. Thanks for reading this blog post, and have a splendid day!