How to install and use pikaur and makepkg on a server
December 8, 2024
How to run pikaur as root
For more information on pikaur, see the article: Automatic installation and update of AUR packages
The makepkg utility and (sometimes) pikaur do not work when run as root. This is not usually a problem for most users, but I have encountered a situation where on a headless server where there is only one user (root), I cannot use pikaur because it does not run as root, and I cannot switch to another user because there is only one user.
When trying to install pikaur, an error occurs:
==> ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system.
There are several ways to get around this limitation. The easiest one, in my opinion, is the following:
1) Create a regular user
2) Install and run pikaur as this regular user
How to create a regular user to run pikaur
You can create a user with the following command (in this and the following commands, replace mial with the name you chose for the new user):
useradd -m -g users -G wheel,video -s /bin/bash mial
Set a password for this user (if this is a work environment, then set a strong password):
passwd mial
How to install pikaur as root
Install the following dependencies:
pacman -S --needed base-devel git pyalpm python-markdown-it-py python-installer python-build python-hatchling
If you have already cloned the pikaur repository to your local machine, then delete this folder, since you downloaded and unzipped the files as root and he is the owner of these files – a regular user does not have permissions to modify the files.
Now go to the home directory of the user you created in the previous step (replace mial with your username in this and all subsequent commands):
cd /home/mial/
To clone the pikaur repository, use a command like this:
sudo -u mial git clone https://github.com/actionless/pikaur
Go to the folder with the pikaur files
cd pikaur/
When trying to install, I encountered an error that the CHANGELOG file was not found:
==> ERROR: changelog file (CHANGELOG) does not exist or is not a regular file.
If you have the same problem, then create it with the following command:
sudo -u mial touch CHANGELOG
Now run the package build and install pikaur with the following command:
sudo -u mial makepkg -fsri
How to run pikaur as root
After installation, pikaur in my case works without errors even if run with root privileges:
pikaur -Syu pikaur -S PACKAGE pikaur -R PACKAGE
However, if you encounter errors due to problems running with root privileges, you can always use the following constructs to run pikaur as a normal user:
sudo -u mial pikaur -Syu sudo -u mial pikaur -S PACKAGE sudo -u mial pikaur -R PACKAGE
Related articles:
- How to view package information in Arch Linux (BlackArch, Manjaro) (76.4%)
- How to download a package without installation in Arch Linux and Manjaro. How to download the AUR package source code (76.4%)
- Error “TypeError: 'AURPackageInfo' does not have attribute 'submitter'” (SOLVED) (73.4%)
- phpMyAdmin error “Error: Undefined constant "SODIUM_CRYPTO_SECRETBOX_KEYBYTES"” (SOLVED) (70.7%)
- Error: failed to commit transaction (conflicting files) (SOLVED) (70.2%)
- Menu buttons (toolbar) and status bar are missing in SMPlayer (SOLVED) (RANDOM - 50.4%)