       (t result))))
 
 (cl-defmethod elisp/runfiles/env-vars--internal
-  ((runfiles elisp/runfiles/runfiles--manifest))
+  ((runfiles elisp/runfiles/runfiles--manifest) remote)
   "Implementation of ‘elisp/runfiles/rlocation’ for manifest-based runfiles.
-RUNFILES is a runfiles object."
-  (list (concat "RUNFILES_MANIFEST_FILE=" (oref runfiles filename))
-        "RUNFILES_DIR" "JAVA_RUNFILES"))
+RUNFILES is a runfiles object, and REMOTE is the remote host
+identifier."
+  (with-slots (filename) runfiles
+    (unless (equal (file-remote-p filename) remote)
+      (signal 'elisp/runfiles/remote (list filename remote)))
+    (list (concat "RUNFILES_MANIFEST_FILE="
+                  (file-name-unquote (file-local-name filename)))
+          "RUNFILES_DIR" "JAVA_RUNFILES")))
 
 (defclass elisp/runfiles/runfiles--directory (elisp/runfiles/runfiles)
   ((directory :initarg :directory :type string))

(define-error 'elisp/runfiles/read-only "Runfiles are read-only" 'file-error)
(define-error 'elisp/runfiles/syntax-error "Syntax error in runfiles manifest")
(define-error 'elisp/runfiles/empty "Empty runfile")



  (cl-check-type runfiles elisp/runfiles/runfiles)
  (elisp/runfiles/rlocation--internal runfiles filename))

(cl-defun elisp/runfiles/env-vars
    (&optional (runfiles (elisp/runfiles/get))
               (remote (file-remote-p default-directory)))
  "Return a list of environmental variable for subprocesses.
Prepend this list to ‘process-environment’ if you want to invoke
a process that should have access to the runfiles.  RUNFILES must
be an object of the class ‘elisp/runfiles/runfiles’; it defaults
to a global instance.  REMOTE must be nil a remote host
identifier (see Info node ‘(elisp) Magic File Names’); if the
returned values are on the same remote host as REMOTE, return the
local names on that host, otherwise signal an error of type
‘elisp/runfiles/remote’."
  (cl-check-type runfiles elisp/runfiles/runfiles)
  (cl-check-type remote (or string null))
  (elisp/runfiles/env-vars--internal runfiles remote))

(defun elisp/runfiles/filename-p (string)
  "Return whether STRING is a possible argument for ‘elisp/runfiles/rlocation’."
