Use kpsewhich and don't rely on "cd"