             (get-buffer name)
           (with-current-buffer
               (get-buffer-create name)
-            (cd root)
-            (intero-repl-mode)
+	    ;; The new buffer doesn't know if the initial buffer was hosted
+	    ;; remotely or not, so we need to extend by the host of the
+	    ;; initial buffer to cd. We could also achieve this by setting the
+	    ;; buffer's intero-buffer-host, but intero-repl-mode wipes this, so
+	    ;; we defer setting that until after.
+            (cd (intero-extend-path-by-buffer-host root initial-buffer))
+            (intero-repl-mode) ; wipes buffer-local variables
+	    (setq intero-buffer-host (intero-buffer-host initial-buffer))
             (intero-repl-mode-start backend-buffer
                                     (buffer-local-value 'intero-targets backend-buffer)
                                     prompt-options)

(defun intero-get-buffer-create (worker)
  "Get or create the stack buffer for WORKER.
Uses the directory of the current buffer for context."
  (let* ((root (intero-project-root))
         (cabal-file (intero-cabal-find-file))
         (package-name (if cabal-file
                           (intero-package-name cabal-file)

   (intero-blocking-call
    'backend
    (format ":uses %S %d %d %d %d %S"
            (intero-localize-path (intero-temp-file-name))
            (save-excursion (goto-char beg)
                            (line-number-at-pos))
            (save-excursion (goto-char beg)
