 error referring to PROG as PROG-NAME and VAR-NAME.  This function
 finds a remote binary when the current buffer is a Tramp file,
 unless LOCAL-ONLY is set."
-  (let* ((local (or local-only (not (fstar--remote-p))))
-         (abs (if local (executable-find prog) prog)))
+  (let* ((local (or local-only (not (fstar--remote-p)))))
     (if local
-        (fstar--check-executable (or abs prog) prog-name var-name)
-      (with-parsed-tramp-file-name buffer-file-name nil
-        (or (tramp-find-executable v abs nil)
+        (fstar--check-executable (executable-find prog) prog-name var-name)
+      (let ((tramp-vect (tramp-dissect-file-name buffer-file-name))
+            (prog-name (concat "Remote " prog-name)))
+        (if (file-name-absolute-p prog)
             (fstar--check-executable
-             (tramp-make-tramp-file-name method user host abs)
-             (concat "Remote " prog-name) var-name))))
-    abs))
+             (concat (file-remote-p buffer-file-name) prog)
+             prog-name var-name)
+          (tramp-find-executable tramp-vect prog nil))))))
 
 (defun fstar-subp-buffer-killed ()
   "Kill F* process associated to current buffer."

  (if (and (eq system-type 'cygwin) (not (fstar--remote-p)))
      (string-trim-right (car (process-lines "cygpath" "-w" path)))
    path))

(defun fstar--make-tramp-file-name (fname)
  "Convert FNAME to a name on remote host."
  (with-parsed-tramp-file-name buffer-file-name nil
    (tramp-make-tramp-file-name method user host fname)))

(defun fstar--tramp-find-executable (prog)
  "Check if PROG is in the remote path."

                (if var-name (format "; please adjust `%s'" var-name) "")))
  (unless (file-executable-p path)
    (user-error "%s (“%s”) not executable%s" prog-name path
                (if var-name (format "; please check `%s'" var-name) "")))
  path)

(defun fstar-find-executable (prog prog-name &optional var-name local-only)
  "Compute the absolute path to PROG.
