Skip to content
Dave Liepmann edited this page Jun 1, 2017 · 6 revisions

Some development scenarios require to run IDE and JS environment on different machines. For example you want to develop for NodeJS running on Raspberry Pi. Your Emacs+Cider or Cursive runs on your dev laptop and NodeJS runs on repl-host machine, let's say an embedded system with ARMv7.

This page describes how to setup remote REPL in such scenario. It assumes you are familiar with tools like ssh, you know how to generate ssh key pairs etc.

Remote NodeJS REPL

To enable remote REPL on NodeJS, you need:

  1. command which invokes node on remote machine
  2. synchronize files between dev and repl-host machines, because ClojureScript Node REPL needs to read compiled files

To make it work:

  1. Install node and ssh server on repl-host machine.

  2. Generate your ssh key pair on dev and add its public part to ~/.ssh/authorized_keys on repl-host machine

  3. Configure your ~/.ssh/config on dev machine:

    Host repl-host
         HostName		repl-host
         User			repl-user
    
  4. Create repl-host-node.sh script and store it in PATH directory. Let's say you have installed node in /opt/node directory.

    #! /bin/bash
    ssh repl-host /opt/node/bin/node "$@"

    Test you can invoke it.

  5. Create shared directory, ClojureScript will use it to store compiled files. It should be accessible by you on dev machine and user on repl-host machine, for example /tmp/cljs-repl-share.

  6. Synchronize dev:/tmp/cljs-repl-share and repl-host:/tmp/cljs-repl-share with a distributed FS, for example NFS, Samba or SSHFS (depends on your system).

  7. Start Clojure REPL on dev and invoke ClojureScript REPL with this script:

    (ns mirabox-sandbox-clojure.node-repl
      (:require [cemerick.piggieback :as piggie]
                [cljs.repl.node      :as node]
                [clojure.java.io     :as io]))
    
    (piggie/cljs-repl (node/repl-env :host "repl-host")
                      :node-command "repl-host-node.sh"
                      :output-dir "/tmp/cljs-repl-share")

    If you do not use piggieback, replace it with cljs.repl namespace.

Synchronize directories using with FUSE and SSHFS (Linux)

The easiest way to synchronize directories on Linux is to mount directory using SSHFS. There is no need to install and configure NFS daemons or Samba. You do not even have to be root to mount a FUSE directory.

$ sshfs -o sshfs_sync repl-host:/tmp/cljs-repl-share /tmp/cljs-repl-share
Clone this wiki locally