            (lambda (recipe)
              (straight--with-plist recipe
                  (package local-repo type)
-               (when (memq profile (gethash package straight--profile-cache))
+               (when (and local-repo
+                          (memq profile
+                                (gethash package straight--profile-cache)))
                  (push (cons local-repo
                              (or (cdr (assoc local-repo versions-alist))
                                  (straight-vc-get-commit type local-repo)))

              (let ((unpushed-recipes
                     (straight-push-all
                      (lambda (package)
                        (straight--repository-is-available-p
                         (gethash package straight--recipe-cache))))))
                (or
                 (null unpushed-recipes)
                 (straight-are-you-sure

       (lambda (recipe)
         (straight--with-plist recipe
             (local-repo package)
           (unless (or (null local-repo)
                       (assoc local-repo versions-alist)
                       (straight--repository-is-available-p recipe))
             (straight-use-package (intern package)))))))
    (dolist (spec straight-profiles)
