Fix while loop in `ensure_package_manager`