Why is yaourt looking in the wrong place (pacman works)?

After removing yaourt and package-query, upgrading pacman to v4.0.1 and reinstalling the latest package-query and yaourt from AUR, I can't use yaourt anymore. It tells me:

Unable to open file: /usr/local/etc/pacman.conf

I don't understand why it's looking there now and not in /etc. Meanwhile pacman is working normally. If I create a symlink to pacman.conf, I get the following error instead:

failed to initialize alpm library (could not find or read directory)

My $PATH is:

/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl

I have tried looking in the yaourt PKGBUILD prior to installing, reinstalling it, looking in the yaourt script file, and I can't find anything suspicious. Not sure what to look for, what could have happened?

EDIT: Found the solution: /usr/bin needs to be before /usr/local/bin in $PATH.


Yaourt apparently uses the first entry in $PATH, so /usr/bin needs to be before /usr/local/bin there.

Changing this in /etc/profile solved the problem.


Reinstall package-query using empty --prefix: ./configure --prefix=


I had the same issue. The problem (as mentioned in other answers) is that if you run:

[linux]$ echo $PATH
[linux]$ /usr/local/sbin:/usr/local/bin:/usr/bin .....

Notice that /usr/local/sbin and /usr/local/bin appear first, so the programs searched for will be taken from these locations (if they exist).

Have a look in /usr/local/bin to see if you can see package-query there; if you can, then your issues are being caused by this, it shouldn't be there (unless you installed it there). So. Lets fix it......

Start by removing YAOURT:

sudo pacman -R yaourt
checking dependencies...

Packages (1) yaourt-1.9-1

Total Removed Size:  0.81 MiB

:: Do you want to remove these packages? [Y/n] y
:: Processing package changes...
(1/1) removing yaourt                                                                                                             [############################################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...

And then remove package-query:

[linux]$ sudo pacman -R package-query
checking dependencies...

Packages (1) package-query-1.9-3

Total Removed Size:  0.08 MiB

:: Do you want to remove these packages? [Y/n] y
:: Processing package changes...
(1/1) removing package-query                                                                                                      [############################################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...

Finally, manually remove the stray package-query binary:

[linux]$ sudo rm -rf /usr/local/bin/package-query

Now, re-install yaourt (and package-query) using the instructions supplied here: https://archlinux.fr/yaourt-en

And you should be good to go.