You do not apply absolutepath to the result returned and hence this could lead `pkg which` to miss files that actually belong to some packages, e.g. when `PATH` contains some relative paths.