How to Use Yay to Install an AUR Package, From Search to First Launch

A practical walkthrough of how to use yay to install an AUR package: searching, choosing the right variant, reviewing the PKGBUILD, building, launching and removing.

How to Use Yay to Install an AUR Package, From Search to First Launch

Yayarch wrote this article for the moment just after yay is installed, when you want to put it to real use. Knowing the command is easy. Knowing how to choose between similar packages, what to look for in a build script and what yay is asking at each prompt is what turns a nervous first install into a routine one. We will follow a complete example from search to first launch, then cover removal and the most common problems.

Start with an up-to-date system

AUR packages are built against the libraries on your machine. If your system is several weeks behind, a new AUR package may expect newer versions than you have. Begin with a full upgrade.

yay

This refreshes the repositories, upgrades everything and checks your existing AUR packages, all in one step.

Searching for the package

Suppose you want Visual Studio Code, the Microsoft build, which is not in the official Arch repositories. Search for it.

yay -Ss visual studio code

Yay searches the repositories and the AUR together. Each result shows where it comes from, its version, its vote count and popularity, and a description. You may see several candidates: an open-source build in the official repositories, a Microsoft binary build in the AUR ending in -bin, and perhaps an insiders edition.

Yay also supports narrow searching. Typing yay linux header first searches for linux and then narrows the results to those that also mention header. That is handy when a plain search returns hundreds of matches.

Using the interactive menu

If you type yay followed by a search term without any flag, yay shows a numbered menu of results and asks which ones to install.

yay vscode

Type the number of the package you want and press enter. This is the quickest way to install something when you are not sure of its exact name.

Choosing the right variant

Before installing, think about which variant suits you.

  • A package ending in -bin uses the upstream project's prebuilt binary. It installs quickly and matches the official release.
  • A package with no suffix usually compiles from a source release. It takes longer and suits people who prefer building what they run.
  • A package ending in -git builds from the latest development commit. It is the freshest and the least predictable.

Check the vote count and popularity too. A well-used package with recent activity is generally well maintained. If a package is marked as orphaned, it has no maintainer at present. That is not automatically a problem, but it is a reason to read the build script with particular care.

Installing with yay -S

Once you know the exact name, install it directly.

yay -S visual-studio-code-bin

Yay now resolves dependencies. Anything available in the official repositories will be installed by pacman. Anything only available in the AUR will be built first, in the correct order.

Answering yay's questions

Yay asks all its questions before building, so that you can leave it to work afterwards. The exact prompts depend on your settings, but a typical first install asks the following.

Clean build

Yay asks which packages to clean build, meaning whether to delete any previous build files before starting. For a first install there is nothing to clean, so the default is fine.

Diffs to show

Yay offers to show the build files. For a new package, it shows the full PKGBUILD and any extra files rather than a comparison. Say yes. This is the moment that matters most.

Provider selection

If a dependency can be satisfied by more than one package, yay lists the providers and asks you to choose. The first option is usually the sensible default.

Reading the PKGBUILD

A PKGBUILD is a short shell script. You do not need to be a programmer to check the important parts.

  • url should point to the genuine project website.
  • source lists what will be downloaded. Check that the addresses belong to the project or a reputable host.
  • sha256sums or similar lines should contain real checksums rather than SKIP, except for version-control sources where SKIP is normal.
  • The prepare(), build() and package() functions should do what you would expect: unpack, compile and copy files into place.

Be suspicious of anything that downloads extra scripts, runs curl or wget inside functions, decodes base64 strings or writes to locations outside the package directory. If an install script is present, read that too, because it runs with root privileges.

Yay version 13 also shows how recently the PKGBUILD was changed. A very recent change on a long-quiet package is worth a second look, although on its own it does not prove anything is wrong.

Building and installing

After you confirm, yay installs any repository dependencies through pacman, then calls makepkg to build the package as your normal user. For a -bin package this mostly means downloading and repackaging. For a source package you will see compiler output scroll past.

When the build finishes, yay hands the package to pacman and asks for your password to install it. Finally, it may offer to remove build-only dependencies that are no longer needed.

First launch and checks

Most desktop applications appear in your application menu straight away. You can also confirm the installation from the terminal.

pacman -Qi visual-studio-code-bin

This shows the version, the install date and the files' owner, confirming that pacman is tracking the package properly. To list every AUR package you have installed, run yay -Qm.

Keeping the package updated

From now on, a normal yay upgrade checks the AUR for new versions of this package and offers to rebuild it. You will see a diff of what changed in the build script, which is usually just a new version number and checksum.

Removing the package

Removal goes through pacman, just like any other package.

yay -Rns visual-studio-code-bin

The -n flag removes backup configuration files and -s removes dependencies no longer required by anything else. Your personal settings in your home directory are left alone.

When things go wrong

Unknown public key

Some packages verify upstream signatures. If makepkg reports an unknown public key, check the AUR page or the project's website for the correct key, import it with gpg and try again. Do not skip verification.

Missing dependency or version conflict

Run a full upgrade, then retry. If the error persists, read the package's AUR comments, where others often post fixes.

Build fails partway through

Large source builds can run out of memory or disk space. Check free space in your home directory and consider the -bin variant if one exists.

The package is out of date

If a package is flagged out of date and you need the new version, look in the comments for an updated PKGBUILD or contact the maintainer politely. Building a modified PKGBUILD yourself is possible, but read every change.

A second example: a source package with AUR dependencies

The Visual Studio Code example used a binary package with no AUR dependencies, which is the simplest case. It is worth knowing what changes when a package must be compiled and depends on other AUR packages.

When you run yay -S on such a package, yay lists the AUR dependencies it will build first. During the review step, it offers the build files for every one of them, not just the package you asked for. Review them all. A malicious dependency is just as dangerous as a malicious main package, and attackers know that dependencies receive less attention.

The build then takes longer, because each package is compiled in turn. You will see makepkg's output for each one, and yay will ask for your password once installation begins. If a dependency fails to build, yay stops and reports which one failed, so you can read that package's AUR comments for a fix.

Speeding up source builds

If you build many source packages, a few makepkg settings can save time. In your makepkg configuration you can raise the number of parallel compile jobs to match your processor's core count, and choose a faster compression method for the finished packages. These settings affect every build, including those started by yay. Change them gradually and keep a note of what you changed, so you can undo anything that causes problems.

Remember that -bin packages are unaffected by compiler settings, because nothing is compiled. If a source build is very slow and a well-maintained -bin package exists, switching may be the simplest improvement of all.

Frequently asked questions

How do I use yay to install an AUR package without prompts?

Yay offers options to skip menus, such as --noconfirm, but skipping the review step removes your main safety check. It is best kept for packages you have already reviewed.

Do I need sudo to install AUR packages with yay?

Run yay as your normal user. It calls sudo itself only for the final installation step.

Where does yay store build files?

In its cache directory inside your home folder. You can clear old builds with yay -Sc.

Can I install several AUR packages at once?

Yes. List them after yay -S, separated by spaces, and yay will resolve and build them in the right order.

Can yay install a local PKGBUILD?

Yes. yay -Bi followed by a directory builds a local PKGBUILD and installs its dependencies.

What does the number next to a package in search results mean?

It is the vote count, followed by a popularity score. Both indicate how widely the package is used.

Why does yay ask to remove make dependencies?

Some packages need tools only while building, such as compilers or code generators. Removing them afterwards keeps your system lean. You can keep them if you build often.

What if two AUR packages provide the same program?

Yay will ask which provider you want. Choose the one that matches your preference for binary, source or development builds, and check its votes and comments.

Can I see what files an AUR package installed?

Yes. Run pacman -Ql package-name to list every file the package placed on your system.

Is it safe to edit a PKGBUILD before building?

Yes, if you understand the change. Yay's edit menu lets you open build files in your editor, which is useful for small fixes suggested in AUR comments.

Conclusion

Learning how to use yay to install an AUR package is mostly about calm habits. Update first, search and compare variants, install with yay -S, read the build files when yay offers them, and let the build run. Confirm the install with pacman, update through normal upgrades and remove with yay -Rns when you are done. Follow that pattern every time and the AUR becomes a dependable extension of your Arch system rather than a source of surprises.