This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-11
Channels
- # aleph (1)
- # architecture (18)
- # beginners (57)
- # boot (13)
- # cider (47)
- # cljs-dev (28)
- # cljsjs (13)
- # cljsrn (39)
- # clojure (258)
- # clojure-greece (16)
- # clojure-italy (2)
- # clojure-miami (1)
- # clojure-nl (9)
- # clojure-poland (15)
- # clojure-russia (369)
- # clojure-spec (53)
- # clojure-uk (49)
- # clojureremote (3)
- # clojurescript (135)
- # core-matrix (1)
- # cursive (11)
- # datascript (3)
- # datomic (4)
- # emacs (12)
- # figwheel (13)
- # hoplon (7)
- # interop (7)
- # jobs-discuss (33)
- # lumo (28)
- # off-topic (15)
- # om (7)
- # onyx (26)
- # pedestal (10)
- # perun (1)
- # planck (10)
- # re-frame (54)
- # reagent (16)
- # ring (5)
- # ring-swagger (50)
- # rum (2)
- # spacemacs (2)
- # unrepl (125)
- # untangled (12)
@jfntn because all the jack in clojure script does is set up a new client and then call some piggy back (or whatever inits your cljs repl)
the magic happens inside cider-create-sibling-cljs-repl
. All it does is read the info from the clj buffer and then create another client on the same ports
the magic happens in this line: (cljs-proc (apply #'nrepl-start-client-process client-process-args))
which just creates a new client process on the same stuff. And then there's the comment that should give you the most confidence to just create clj repls and init one for cljs and leave the other alone:
;; The new connection has now been bumped to the top, but it's still a
;; Clojure REPL! Additionally, some ClojureScript REPLs can actually take
;; a while to start (some even depend on the user opening a browser).
;; Meanwhile, this REPL will gladly receive requests in place of the
;; original Clojure REPL. Our solution is to bump the original REPL back
;; up the list, so it takes priority on Clojure requests.
then, the remaining code is very straight forward. It sets the connection as default (by putting it at the beginning of the connection list, sends a message that the cljs repl is being created, and then the code following that just invokes whatever code is required to get your cljs repl up:
(cider-nrepl-send-request
`("op" "eval"
"ns" ,(cider-current-ns)
"code" ,cljs-repl-form)
(cider-repl-handler (current-buffer)))
(cider--offer-to-open-app-in-browser nrepl-server-buffer)
so if i remember what you are wanting to do, you want to create a clojure repl under one profile and then a clojurescript repl under another. And all you need to do is jack in with a profile and then jack in with another profile. In the one you want to be cljs, invoke whatever cljs stuff you need. For piggyback this is simply: (cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))
dpsutton that’s really helpful! I’ll have to get back to this tomorrow, but I think I just assumed I didn’t want to create a new client like the sibling code does, which must be why it didn’t block until the buffer was ready and the rest didn’t work. Will report back, thanks for the detailed explanation!
feel free to message me tomorrow. i'll be at work but i've dug through some of this before
@qqq you might also consider filing a ticket - I don’t usually have time to follow discussions here, but I usually read tickets and respond to them
has anyone ever had problems of using cider-refresh with .cljc files that have some reader conditionals? code builds, repl starts with no problems, but then if I do cider-refresh - it complains ;(
this is probably not a bug in cider. probably I’m doing something wrong, but I can’t figure out the cause
@ag http://dev.clojure.org/jira/browse/TNS-42 could it be this?
@dominicm does that mean that I should also see some problems if I manually try to use clojure.tools.namespace.repl :refer [refresh]
?
so I’m trying to run cider-refresh
, it complains that it can’t load .cljc namespace. and then apparently repl kinda breaks - I can’t switch namespaces, evaluating anything does not show anything ;(
it turn out to be cider-refresh
problem after all - I can’t replicate it with :relooad-all true
@ag I’m happy with cider-refresh
stuff, moreover added stuartsierra/component
features there and it works great for reloading. and I believe you should fix that issue with cljc
@ag looks like you narrowed it down to some elisp issue? The elisp debugger should be able to get some context if you can afford the yak shave!
> @ag repl starts with no problems, but then if I do cider-refresh - it complains ;(. What is the exception you’re seeing there. I’m working with cljc no issue so far
so I have some .cjc files with specs and generators, when I jack-in - everything is fine. If I try to use cider-refresh
- it complains “error loading foo namespace” where foo is that .cljc file
it throws
java.lang.AssertionError
Assert failed: Second arg to such-that must be a generator (generator? gen)
generators.cljc: 346 clojure.test.check.generators$such_that/invokeStatic
generators.cljc: 328 clojure.test.check.generators$such_that/invoke
AFn.java: 160 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 641 clojure.core/apply
gen.clj: 94 clojure.spec.gen/eval12564/such-that
RestFn.java: 436 clojure.lang.RestFn/invoke
spec.clj: 272 clojure.spec/gensub
spec.clj: 264 clojure.spec/gensub
spec.clj: 288 clojure.spec/gen
spec.clj: 277 clojure.spec/gen
spec.clj: 287 clojure.spec/gen
spec.clj: 277 clojure.spec/gen
AFn.java: 154 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
Compiler.java: 3652 clojure.lang.Compiler$InvokeExpr/eval
Compiler.java: 3651 clojure.lang.Compiler$InvokeExpr/eval
Compiler.java: 3651 clojure.lang.Compiler$InvokeExpr/eval
Compiler.java: 451 clojure.lang.Compiler$DefExpr/eval
Compiler.java: 6932 clojure.lang.Compiler/eval
Compiler.java: 7379 clojure.lang.Compiler/load
RT.java: 372 clojure.lang.RT/loadResourceScript
RT.java: 363 clojure.lang.RT/loadResourceScript
RT.java: 453 clojure.lang.RT/load
RT.java: 419 clojure.lang.RT/load
core.clj: 5893 clojure.core/load/fn
core.clj: 5892 clojure.core/load
core.clj: 5876 clojure.core/load
RestFn.java: 408 clojure.lang.RestFn/invoke
core.clj: 5697 clojure.core/load-one
core.clj: 5692 clojure.core/load-one
core.clj: 5737 clojure.core/load-lib/fn
core.clj: 5736 clojure.core/load-lib
core.clj: 5717 clojure.core/load-lib
RestFn.java: 142 clojure.lang.RestFn/applyTo
core.clj: 648 clojure.core/apply
core.clj: 5774 clojure.core/load-libs
core.clj: 5758 clojure.core/load-libs
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 648 clojure.core/apply
core.clj: 5796 clojure.core/require
core.clj: 5796 clojure.core/require
RestFn.java: 421 clojure.lang.RestFn/invoke
reload.clj: 35 cider.inlined-deps.toolsnamespace.v0v3v0-alpha3.clojure.tools.namespace.reload/track-reload-one
reload.clj: 21 cider.inlined-deps.toolsnamespace.v0v3v0-alpha3.clojure.tools.namespace.reload/track-reload-one
reload.clj: 52 cider.inlined-deps.toolsnamespace.v0v3v0-alpha3.clojure.tools.namespace.reload/track-reload
reload.clj: 43 cider.inlined-deps.toolsnamespace.v0v3v0-alpha3.clojure.tools.namespace.reload/track-reload
refresh.clj: 155 cider.nrepl.middleware.refresh/refresh-reply/fn
core.clj: 1941 clojure.core/binding-conveyor-fn/fn
AFn.java: 154 clojure.lang.AFn/applyToHelper
RestFn.java: 132 clojure.lang.RestFn/applyTo
Agent.java: 114 clojure.lang.Agent$Action/doRun
Agent.java: 163 clojure.lang.Agent$Action/run
ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 745 java.lang.Thread/run
1. Caused by clojure.lang.Compiler$CompilerException
interestingly there’s nothing wrong with the code, when evaluated the first time (before refresh) it works just fine
I’d make sure there I don’t have a faulty top-level form, but I’ve also ran into situations where some libraries make reloading impossible, seems to happen more often on cljc projects
I don’t think cljc
is source of the issue here. seems like mistyping or something similar
so when I do (require ’[foo :reload-all true]) in the terminal it works just fine. If I try to do the same thing after cider-refresh - it complains ;(
isn’t the difference that when doing it manually you only reload foo, but cider tries to reload all namespaces?
cider just call (require '[clojure.tools.namespace.repl :refer [refresh]) (refresh)
. Not sure if it may help
> isn’t the difference that when doing it manually you only reload foo, but cider tries to reload all namespaces? probably, yes
that’s the thing - when I call refresh manually - nothing happens, everything works as expected. But when I do cider-refresh, it complains about that single .cljc file