Fork me on GitHub

i think you're in luck


@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)


so all you really have to do is just jack in and then invoke whatever you want


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:

       `("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


appreciate it, thanks!


@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


what is it complaining about?


cljc support is rather spotty. just wondering


@dominicm does that mean that I should also see some problems if I manually try to use :refer [refresh] ?


I’m not seeing any


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!


@jfntn it throws java error though


sorry, I missed beginning of conversation


> @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


you’ve tried lein clean already, right? and restarting the repl


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


and what happens if you go to that file and call C-c C-k there?


I’m not using lein it’s a boot project - but I don’t think that’s the issue


it throws

   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
          160  clojure.lang.AFn/applyToHelper
          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
       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
          154  clojure.lang.AFn/applyToHelper
          144  clojure.lang.AFn/applyTo
    3652  clojure.lang.Compiler$InvokeExpr/eval
    3651  clojure.lang.Compiler$InvokeExpr/eval
    3651  clojure.lang.Compiler$InvokeExpr/eval
     451  clojure.lang.Compiler$DefExpr/eval
    6932  clojure.lang.Compiler/eval
    7379  clojure.lang.Compiler/load
           372  clojure.lang.RT/loadResourceScript
           363  clojure.lang.RT/loadResourceScript
           453  clojure.lang.RT/load
           419  clojure.lang.RT/load
                  core.clj: 5893  clojure.core/load/fn
                  core.clj: 5892  clojure.core/load
                  core.clj: 5876  clojure.core/load
       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
       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
       137  clojure.lang.RestFn/applyTo
                  core.clj:  648  clojure.core/apply
                  core.clj: 5796  clojure.core/require
                  core.clj: 5796  clojure.core/require
       421  clojure.lang.RestFn/invoke
                reload.clj:   35
                reload.clj:   21
                reload.clj:   52
                reload.clj:   43
               refresh.clj:  155  cider.nrepl.middleware.refresh/refresh-reply/fn
                  core.clj: 1941  clojure.core/binding-conveyor-fn/fn
          154  clojure.lang.AFn/applyToHelper
       132  clojure.lang.RestFn/applyTo
        114  clojure.lang.Agent$Action/doRun
        163  clojure.lang.Agent$Action/run 1142  java.util.concurrent.ThreadPoolExecutor/runWorker  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
       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


may be it’s just not load when you run the repl?


is test file you working with? if you run tests they work?


I think this is something to do with com.gfredericks/test.chuck


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 ;(


it breaks, the only way to fix it - to restart the repl


which is quite annoying


isn’t the difference that when doing it manually you only reload foo, but cider tries to reload all namespaces?


cider just call (require '[ :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




most likely way you do when I call refresh manually is not loading this cljc file. In contrast what cider-refresh do, which is also trivial and calls :refer [refresh] function


that’s what I’m saying - if I execute in the repl, it works just fine.