How to Install and Setup Yay on Arch Linux?
If you use Arch Linux or a similar distro, you probably know that Pacman is a default package manager for Arch systems. But pacman can’t directly download AUR packages in Arch Linux. The Arch User Repository (AUR) contains many user-made packages, commonly referred to as PKGBUILDs. To get these packages, you need an AUR helper like Yay. But how do you install Yay if it’s not in the official repositories or on your system by default? This brief article will cover the method to install Yay on Arch Linux.
Installing Yay on Arch Linux
To install and set up Yay on Arch Linux, you need to follow these steps:
1. Install the prerequisite packages by running the following command:
sudo pacman -Syu
This command updates the package list and upgrades all packages on the system.
Next, install the base-devel and git packages.
sudo pacman -S --needed base-devel git
The –needed flag will prevent the duplicate installation of packages. The base-devel package has all the essential tools like makepkg, that are required for compiling from source. The git package is required for cloning repositories from sources like AUR.
2. Clone the Yay git repository using the following command:
sudo git clone https://aur.archlinux.org/yay.git
This command clones the yay package from the Arch User Repository (AUR) using git.
3. Navigate into the yay folder and build the package from PKGBUILD using the following command:
cd yay
The cd command changes your current directory to the newly created yay directory.
Next, use the makepkg command to build and install the yay package.
makepkg -si
Sometimes, you may get a permission error while building the yay package file. This is because you do not have write access to the directory where you are trying to build the package.
To fix this, you can change the ownership of the directory to your user account using the command:
sudo chown -R user:user /home/user/yay
where the user is your username. This will give you full control over the directory and its contents.
Secondly, you can change the location of the build directory to a place where you have write access. For example, you can use the /tmp. You can do this by setting the environment variable BUILDDIR before running makepkg, like this:
BUILDDIR=/tmp makepkg -si
This will create a temporary directory under /tmp and build the package there. After installation check the Yay installed version:
yay --version
Once you have installed Yay, you can use it to upgrade all the packages on your system. The yay also allows you to install the new packages or remove the old ones.
How to Manage AUR Packages Using Yay
You can use yay to easily search, install, and manage packages from AUR on Arch Linux and its sub-distributions like the Manjaro. Now we will cover different ways of using the yay on Arch Linux:
Update System and Packages
You can run yay or yay -Syu to update Arch Linux. This is the same as running pacman -Syu:
yay
This will update the package database and upgrade the previously installed packages of your system.
You can also use the yay -Syu command to synchronize with the repositories and upgrade all packages, including those from the AUR.
yay -Syu
This command is equivalent to pacman -Syu, but with support for AUR packages.
Update AUR Packages Only
If you only want to upgrade the packages that you installed from Yay, you can run yay -Sua:
yay -Sua
Check for Updates
You can run yay -Qua to see the available updates for all the packages you installed from Yay, without upgrading them.
yay -Qua
Or you can run yay -Qu to also include the pending updates for the packages that you installed from the official repositories.
yay -Qu
Search for an AUR Package
You can run yay followed by the package name (e.g., firefox) to search in the official Arch package repositories or inside the AUR repository. For example:
yay firefox
Or
yay -Ss firefox
The above command will list all the matched packages and allow you to manually select the package of your choice to install.
Install an AUR Package
You can run yay -S followed by the package name (e.g., neofetch) to install a package. This command can also install any of the packages from either the official repositories or the AUR repository. For example:
yay -S neofetch
Tip: If you are unsure about the exact AUR package name. You can check out the AUR official website for the exact package name.
Print Package Information
You can run yay -Si followed by the package name (e.g., neofetch) to print the information about the installed or uninstalled package. This command will display the information of packages despite their installation source (Official repository or AUR). For example:
yay -Si neofetch
Remove an AUR Package
To remove the AUR package using the yay command, add the -R flag and define the package name. For example, to remove the neofetch package, run:
yay -R neofetch
Clean Package Cache
To clear the package cache and get rid of the unnecessary packages and dependencies, you can use this command:
yay -Sc
Print the System Statistics
To see how many packages you have installed and how much space they are taking, you can use the yay -Ps command.
yay -Ps
This command will also show you how big the caches of pacman and yay are. The cache of packages irrespective of the installation source (pacman or yay) will be displayed.
Are Yay or AUR Packages Safe?
AUR packages are user-contributed, which means that they are not built by the official Arch support. Some AUR packages may not be secure. However, the Arch users do check the AUR. They check packages that users report, new packages that users submit, and pkgbuilds at random.
It is recommended to always review the PKGBUILD file and the code of the package before installing it from the AUR. Also, you may find some AUR packages that are not updated as frequently or as reliable as the official packages. This can lead to stability problems inside your system. So be always careful while installing and updating the AUR packages.
Secondly, using multiple AUR helpers together like the Yay, Pakku, and Pacaur can lead to conflict with each other. Prefer only one AUR helper to avoid issues. However, if you find it difficult to use AUR helper, you always have the choice of installing the AUR packages manually like we did for the yay installation.
How to Remove Yay from Arch Linux?
To remove yay from your Arch system, run:
sudo pacman -Rs yay
What Happens to AUR Packages When You Remove Yay?
Yay, is an AUR package manager that downloads, builds, and installs packages from the AUR. In case you remove yay, it will not affect the packages installed from AUR using yay. All these packages will remain installed on Arch. Later, if you decide to remove those packages, you can uninstall those AUR packages using the pacman package manager. For that, use pacman -Rs, and describe the package name after it.
Conclusion
The yay is an AUR helper for directly installing the AUR packages. As the default package manager, pacman does not have any support for AUR package installation. So, you have to rely on any AUR helper like yay. These AUR helpers can help you to install and manage AUR packages. To install yay, first, install some prerequisites like git and clone the yay git repository. After that, build the packages from PKGBUILD. Once installed, you can manage AUR packages directly from the console of your Arch system.
It is important to note that AUR packages are user-contributed and may not be as secure or reliable as official packages. So it is recommended to review the PKGBUILD file and the code of the package before installing it from the AUR.