                        props))
          ,@body))))
 
-;; We don't define `straight--profile-cache' until later. I don't
-;; think it's possible to avoid the circular dependency in any sane
-;; way, since the VC layer is used to clone packages and we need to
-;; clone Magit here.
-(defvar straight--profile-cache)
-
-(cl-defun straight--magit-status (directory)
-  "Like `magit-status', but install Magit if necessary.
-Magit is only installed if the user responds to a `y-or-n-p'
-prompt. Return non-nil if Magit was installed. DIRECTORY is as in
-`magit-status'."
-  (unless (or (require 'magit nil 'noerror)
-              (gethash "magit" straight--profile-cache))
-    (if (y-or-n-p "Install Magit? ")
+(defun straight--ensure-magit-p (feature)
+  "Load Magit FEATURE and return non-nil if it's avaliable.
+If the feature isn't available, offer to install Magit with a
+`y-or-n-p' prompt before loading it."
+  (or (require feature nil 'noerror)
+      (when (y-or-n-p "Install Magit? ")
         (straight-use-package 'magit)
-      (cl-return-from straight--magit-status)))
-  (prog1 t
-    (magit-status-setup-buffer directory)))
+        (require feature nil 'noerror))))
+
+(defun straight--magit-status (directory)
+  "Like `magit-status', but offer to install Magit if necessary.
+Return non-nil if `magit-status-setup-buffer' is invoked successfully.
+DIRECTORY is as in `magit-status'."
+  (when (and (straight--ensure-magit-p 'magit-status)
+             (fboundp 'magit-status-setup-buffer))
+    (magit-status-setup-buffer directory)
+    t))
 
 (defun straight--recursive-edit ()
   "Start a new recursive edit session.
 Make sure that other packages such as `server.el' don't cause us
-to loose our session."
+to lose our session."
   ;; Don't mess up recursive straight.el operations. The wonderful
   ;; thing about using our own variable is that since it's not
   ;; buffer-local, a recursive binding to nil is actually able to

(declare-function flycheck-checker-get "flycheck")
(declare-function flycheck-get-next-checker-for-buffer "flycheck")
(declare-function flycheck-start-current-syntax-check "flycheck")

;; `magit'
(declare-function magit-status-setup-buffer "magit-status")

;; `package'
(defvar package-selected-packages)

                              remote local-repo))))
      (while t
        (and (straight-vc-git--ensure-local recipe)
             (or (straight-vc-git--ensure-default-branch-current
                  local-repo remote-branch
                  (format "%s/%s" remote remote-branch))
                 (straight-register-repo-modification local-repo))
