vagrant box add ubuntu/trusty64
vagrant init ubuntu/trusty64
cat Vagrantfile
vagrant up
vagrant ssh -c 'lsb_release -a'
vagrant ssh -c 'sudo apt-get update'
vagrant ssh -c 'sudo apt-get install -y git emacs openjdk-7-jdk leiningen'
turns out lein is version 1.7, we will upgrade it manually
vagrant ssh -c 'curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
vagrant ssh -c 'chmod +x lein && sudo mv lein /usr/local/bin/lein'
vagrant ssh -c 'lein version'
vagrant ssh -c 'git clone https://github.com/plexus/chestnut && cd chestnut && lein install'
vagrant ssh -c 'lein new chestnut test1'
create ~/.lein/profiles.clj
and add this to it
{:user {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]]
:dependencies [[org.clojure/tools.nrepl "0.2.10"]]}}
(this is showing the first run)
cd test1
lein repl
in the repl, (run)
test1.server=> (run) Figwheel: Starting server at http://localhost:3449 Starting web server on port 10555. 2015-09-07 00:05:19.146:INFO:oejs.Server:nREPL-worker-3: jetty-9.2.10.v20150310 2015-09-07 00:05:19.231:INFO:oejs.ServerConnector:nREPL-worker-3: Started ServerConnector@50ea5f23{HTTP/1.1}{0.0.0.0:10555} 2015-09-07 00:05:19.245:INFO:oejs.Server:nREPL-worker-3: Started @157999ms #object[org.eclipse.jetty.server.Server 0x191fe145 "org.eclipse.jetty.server.Server@191fe145"] test1.server=> Compiling "resources/public/js/app.js" from ["src/cljs" "env/dev/cljs"]... Successfully compiled "resources/public/js/app.js" in 11.363 seconds. notifying browser that file changed: resources/public/js/app.js notifying browser that file changed: resources/public/js/out/goog/deps.js notifying browser that file changed: /test1/core.js notifying browser that file changed: /test1/main.js
launch a fresh `emacs` window, and in the *scratch*
buffer, eval
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
M-x package-refresh-contents [RET]
now we should be able to install cider
M-x package-install [RET] cider [RET]
now open test1/src/cljs/test1/core.cljs
, and
M-x cider-connect [RET] [RET] [RET]
(got a prompt to associate with a project, and responded =y [RET]= with the default project directory offered (test1)
in the connected prompt,
(browser-repl)
open browser to http://localhost:10555/
in the cider repl window:
; CIDER 0.10.0alpha (package: 20150906.1311) (Java 1.7.0_79, Clojure 1.7.0, nREPL 0.2.10) test1.server> (browser-repl) << started Weasel server on ws://0.0.0.0:9001 >> << waiting for client to connect ... connected! >> To quit, type: :cljs/quit nil cljs.user> test1.core> (swap! app-state assoc :text "GREAT!") WARNING: Use of undeclared Var test1.core/app-state at line 1 <cljs repl> {:text "GREAT!"} test1.core>
src/cljs/test1/foo.cljs
(ns test1.foo)
(def X (atom {:ping "pong"}))
once saved, the auto-reload picks up the file and shows in the repl window,
notifying browser that file changed: resources/public/js/app.js notifying browser that file changed: /test1/foo.js
now edit src/cljs/test1/core.cljs
so it is now
(ns test1.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[test1.foo :as foo])) ;; changed
(enable-console-print!)
(defonce app-state (atom {:text (str "Hello Chestnut!" (:ping @foo/X))})) ;; changed
(defn main []
(om/root
(fn [app owner]
(reify
om/IRender
(render [_]
(dom/h1 nil (:text app)))))
app-state
{:target (. js/document (getElementById "app"))}))
on save, the emacs (browser-repl repl) shows
clojure.lang.ExceptionInfo: No such namespace: test1.foo, could not locate test1/foo.cljs, test1/foo.cljc, or Closure namespace "test1.foo" {:tag :cljs/analysis-error} at clojure.core$ex_info.invoke(core.clj:4593) at cljs.analyzer$error.invoke(analyzer.cljc:535) at cljs.analyzer$error.invoke(analyzer.cljc:533) at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:1637) at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:2470) at cljs.analyzer$analyze_STAR_$fn__3583.invoke(analyzer.cljc:2551) at clojure.lang.PersistentVector.reduce(PersistentVector.java:333) at clojure.core$reduce.invoke(core.clj:6518) at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2551) at cljs.analyzer$analyze.invoke(analyzer.cljc:2566) at cljs.repl$evaluate_form.invoke(repl.cljc:439) at cljs.repl$eval_cljs.invoke(repl.cljc:559) at cljs.repl$repl_STAR_$read_eval_print__5973.invoke(repl.cljc:835) at cljs.repl$repl_STAR_$fn__5979$fn__5988.invoke(repl.cljc:874) at cljs.repl$repl_STAR_$fn__5979.invoke(repl.cljc:873) at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1053) at cljs.repl$repl_STAR_.invoke(repl.cljc:837) at cemerick.piggieback$run_cljs_repl.invoke(piggieback.clj:169) at clojure.lang.AFn.applyToHelper(AFn.java:171) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invoke(core.clj:634) at cemerick.piggieback$evaluate.invoke(piggieback.clj:258) at clojure.lang.Var.invoke(Var.java:379) at cemerick.piggieback$wrap_cljs_repl$fn__6463$fn__6465$fn__6466.invoke(piggieback.clj:290) at cemerick.piggieback$enqueue$fn__6449.invoke(piggieback.clj:246) at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__1497.invoke(interruptible_eval.clj:159) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
but subsequent evals of @foo/X
work as expected
test1.core> @foo/X {:ping "pong"}
evaling the ns
expr in core.cljs
(via C-x C-e
at the declaration) produces the same error (with or without reloading the browser)
clojure.lang.ExceptionInfo: No such namespace: test1.foo, could not locate test1/foo.cljs, test1/foo.cljc, or Closure namespace "test1.foo" {:tag :cljs/analysis-error} at clojure.core$ex_info.invoke(core.clj:4593) at cljs.analyzer$error.invoke(analyzer.cljc:535) at cljs.analyzer$error.invoke(analyzer.cljc:533) at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:1637) at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:2470) at cljs.analyzer$analyze_STAR_$fn__3583.invoke(analyzer.cljc:2551) at clojure.lang.PersistentVector.reduce(PersistentVector.java:333) at clojure.core$reduce.invoke(core.clj:6518) at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2551) at cljs.analyzer$analyze.invoke(analyzer.cljc:2566) at cljs.repl$evaluate_form.invoke(repl.cljc:439) at cljs.repl$eval_cljs.invoke(repl.cljc:559) at cljs.repl$repl_STAR_$read_eval_print__5973.invoke(repl.cljc:835) at cljs.repl$repl_STAR_$fn__5979$fn__5988.invoke(repl.cljc:874) at cljs.repl$repl_STAR_$fn__5979.invoke(repl.cljc:873) at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1053) at cljs.repl$repl_STAR_.invoke(repl.cljc:837) at cemerick.piggieback$run_cljs_repl.invoke(piggieback.clj:169) at clojure.lang.AFn.applyToHelper(AFn.java:171) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invoke(core.clj:634) at cemerick.piggieback$evaluate.invoke(piggieback.clj:258) at clojure.lang.Var.invoke(Var.java:379) at cemerick.piggieback$wrap_cljs_repl$fn__6463$fn__6465$fn__6466.invoke(piggieback.clj:290) at cemerick.piggieback$enqueue$fn__6449.invoke(piggieback.clj:246) at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__1497.invoke(interruptible_eval.clj:159) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) test1.core>
if I create a new variable in foo.cljs
and either save foo.cljs
or eval the def
, it picks up in the repl
test1.core> foo/Y 1 test1.core> foo/Z 2
so it looks like it’s just the ns
part