Getting yay to autofill the sudo password

I am trying to install a huge package which requires constant building and constant sudo password in order to then install it on my system. How would I get yay to automatically fill in the sudo password everytime it needs it while it is building the packages as it keeps timing out if I am leave my PC unattended?

1 Like

You could change timeout for sudo… or config it to allow without password… man sudo

7 Likes

You can use the option --sudoloop with yay. That will keep it from timing out during long operations. Alternatively, you can set that option in yay’s config.

IMO, that is less risky than globally changing the sudo timeout.

17 Likes

There you go unix_lover, once again you brought out the experts with their expert tips :ok_hand:

3 Likes

sure this would be more unrisky!

2 Likes

For the future this information is also readily available via:

yay --help
5 Likes

In case any other noobs cannot find it…open your terminal,

nano $HOME/.config/yay/config.json

and set the sudoloop to true,
ctrl-x to exit, y to save.

Instead of editing the file directly, you can also just use the --save option.

yay --sudoloop --save

The developer recommends this approach to avoid a syntax error in the json file.

2 Likes

And if you don’t have a .config/yay/config.JSON file, Dalto’s command will create it for you. (For noobs that looked for it and couldn’t find it…)

Also, for those that interested, pikaur is a yay alternative that does the sudo upfront when launched without needing to re-enter during a long install. No special configuration required - it works that way by default.

1 Like

Bumping the topic, Ik
But this file no longer exists on the newer builds of yay

It isn’t created until you change the settings. Just run this command:

yay --sudoloop --save
3 Likes

I think we could use now pacaur I believe that we can do sudo pacaur -S <package_name>.

You could have always used pacaur if you prefer it. That being said, it hasn’t received any commits or maintenance in 7 months.

If you prefer that style of helper you might look at pikaur which is similar.

3 Likes

Could give that a try, thanks mate :slight_smile:

I use pikaur primarily. It works really well. Every once and a while I try something else (yay, paru). I always come back to pikaur. No particular reason, just personal preference.

1 Like

The only problem is that with pikaur, it always fetches things from the AUR, including Firefox. I want it to be more like yay where it only gets it from the AUR when its not available in the ArchLinux repo

That is how it works by default. What arguments are you passing it?

Also, how is that even possible? Any version of firefox in the AUR would have to have a different package name.

Oh, well pikaur -S firefox

My mistake I assumed that it would be different cause it kinda looked like it was getting from AUR, because of the view. It hought it would show the same thing as if I were running pacman.

Whenever I have to build a very large AUR package, including multiple AUR dependency builds, I use the --noinstall option in trizen.

This will build the large AUR package + dependencies unattended, complete (if no build errors), but will not install them.

I leave the build to do its thing, come back later and install the large package with the --nobuild option in trizen, as the binaries have already been built.

1 Like