Move package-manager waiting code to `ensure_package_manager`