validatePkgConfig failed due to a wrong variable scope, as reported in issue #100834. This change corrects the variable scoping.