     '(("e" "Dired and open recursive edit"
        (lambda ()
          (dired (or straight--default-directory default-directory))
-         (recursive-edit)))
+         (let ((straight--default-directory nil))
+           (recursive-edit))))
       ("g" "Magit and open recursive edit"
        (lambda ()
-         (magit-status-internal
-          (or straight--default-directory default-directory))
-         (recursive-edit)))))))
+         (when (straight--magit-status
+                (or straight--default-directory default-directory))
+           (let ((straight--default-directory nil))
+             (recursive-edit)))))))))
 
 (defmacro straight-vc-git--popup (prompt &rest actions)
   "Same as `straight-popup', but specialized for vc-git methods.

      (let ((straight--default-directory nil))
        (recursive-edit)))
     ("g" "Magit and open recursive edit"
      (magit-status-internal
       (or straight--default-directory default-directory))
      (let ((straight--default-directory nil))
        (recursive-edit)))))

(defun straight-vc-git--encode-url (repo host &optional protocol)
  "Generate a URL from a REPO depending on the value of HOST and PROTOCOL.


;;;;;; Utility functions

;; We don't define `straight--profile-cache' until later. (Should some
;; things be rearranged to make this unnecessary?)
(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? ")
        (straight-use-package 'magit)
      (cl-return-from straight--magit-status)))
  (prog1 t
    (magit-status-internal directory)))

(defun straight-vc-git--popup-raw (prompt actions)
  "Same as `straight-popup-raw', but specialized for vc-git methods.
Two additional actions are inserted at the end of the list: \"e\"
