-
Notifications
You must be signed in to change notification settings - Fork 788
Remote REPL
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.
To enable remote REPL on NodeJS, you need:
- command which invokes node on remote machine
- synchronize files between dev and repl-host machines, because ClojureScript Node REPL needs to read compiled files
To make it work:
-
Install node and ssh server on repl-host machine.
-
Generate your ssh key pair on dev and add its public part to
~/.ssh/authorized_keys
on repl-host machine -
Configure your
~/.ssh/config
on dev machine:Host repl-host HostName repl-host User repl-user
-
Create
repl-host-node.sh
script and store it inPATH
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.
-
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
. -
Synchronize
dev:/tmp/cljs-repl-share
andrepl-host:/tmp/cljs-repl-share
with a distributed FS, for example NFS, Samba or SSHFS (depends on your system). -
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.
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
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)