   (expand-file-name filename (oref runfiles directory)))
 
 (cl-defmethod elisp/runfiles/env-vars--internal
-  ((runfiles elisp/runfiles/runfiles--directory))
+  ((runfiles elisp/runfiles/runfiles--directory) remote)
   "Implementation of ‘elisp/runfiles/env-vars’ for directory-based runfiles.
-RUNFILES is a runfiles object."
+RUNFILES is a runfiles object, and REMOTE is the remote host
+identifier."
   (with-slots (directory) runfiles
-    (list "RUNFILES_MANIFEST_FILE"
-          (concat "RUNFILES_DIR=" directory)
-          ;; TODO(laszlocsomor): remove JAVA_RUNFILES once the Java launcher
-          ;; can pick up RUNFILES_DIR.
-          (concat "JAVA_RUNFILES=" directory))))
+    (unless (equal (file-remote-p directory) remote)
+      (signal 'elisp/runfiles/remote (list directory remote)))
+    (let ((directory (file-name-unquote (file-local-name directory))))
+      (list "RUNFILES_MANIFEST_FILE"
+            (concat "RUNFILES_DIR=" directory)
+            ;; TODO(laszlocsomor): remove JAVA_RUNFILES once the Java launcher
+            ;; can pick up RUNFILES_DIR.
+            (concat "JAVA_RUNFILES=" directory)))))
 
 (provide 'elisp/runfiles/runfiles)
 ;;; runfiles.el ends here

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

(cl-defun elisp/runfiles/env-vars (&optional (runfiles (elisp/runfiles/get)))
  "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."
  (cl-check-type runfiles elisp/runfiles/runfiles)
  (elisp/runfiles/env-vars--internal runfiles))

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

      (t result))))

(cl-defmethod elisp/runfiles/env-vars--internal
  ((runfiles elisp/runfiles/runfiles--manifest) remote)
  "Implementation of ‘elisp/runfiles/rlocation’ for manifest-based 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))
