fix crash when non-directories exist in the pkg/ folder