Code is so similar to the https://github.com/clojure/clojurescript/blob/fef7d05ab398bb20acf07d16cb16aa467631f279/src/main/clojure/cljs/repl/browser.clj#L482 that it's either a subtle bug elsewhere or I am being a muppet.
Yeah, I'm not demonstrably a muppet this time. Needs to be "-c -r" to generate it though. I'll log a bug.
thanks
https://github.com/vouch-opensource/krell/wiki/nREPL-Piggieback-Cider
untested but I believe everything is in place
Thanks for that @dnolen I’ll give it a spin right away
feel free report any tweaks this needs
I won't be able to help out wrt. to actually trying this, busy with other stuff - but I don't think there's anything missing to make it work
krell.api/build
is generally useful for scripts
(krell.api/build :some-build {:verbose true} "more_opts.edn")
works
all options merged left to right
The first thing that is missing is '[<http://clojure.java.io|clojure.java.io> :as io]
in the :require
clause, as io
is used.
fixed thanks
This is what happens. I eval this in Emacs:
(setq cider-custom-cljs-repl-init-form
"(require '[cider.piggieback]
'[<http://clojure.java.io|clojure.java.io> :as io]
'[krell.api :as krell]
'[krell.repl])
(def config (slurp (io/file \"build.edn\")))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))")
From the root of the project, where deps.edn
is, I run M-x cider-jack-in-cljs
, which runs:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.2"} refactor-nrepl {:mvn/version "2.4.0"} cider/cider-nrepl {:mvn/version "0.24.0"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
Then I’m prompted what REPL type I want, and I type custom
.
The REPL starts, and this is returned:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
nil#'user/configFileNotFoundException {:main awesome-project.core
:output-to "target/main.js"
:output-dir "target"}
(No such file or directory) <http://java.io|java.io>.FileInputStream.open0 (FileInputStream.java:-2)
IllegalArgumentException Don't know how to create ISeq from: java.lang.Character clojure.lang.RT.seqFrom (RT.java:550)
need to see a full stracktrace - no much use otherwise
RT.java: 550 clojure.lang.RT/seqFrom
RT.java: 530 clojure.lang.RT/seq
core.clj: 137 clojure.core/seq
core.clj: 717 clojure.core/concat/fn
LazySeq.java: 40 clojure.lang.LazySeq/sval
LazySeq.java: 49 clojure.lang.LazySeq/seq
RT.java: 528 clojure.lang.RT/seq
core.clj: 137 clojure.core/seq
core.clj: 726 clojure.core/concat/cat/fn
LazySeq.java: 40 clojure.lang.LazySeq/sval
LazySeq.java: 49 clojure.lang.LazySeq/seq
Cons.java: 39 clojure.lang.Cons/next
RT.java: 1785 clojure.lang.RT/boundedLength
RestFn.java: 130 clojure.lang.RestFn/applyTo
core.clj: 659 clojure.core/apply
core.clj: 652 clojure.core/apply
REPL: 8 user/eval21162
REPL: 8 user/eval21162
Compiler.java: 7062 clojure.lang.Compiler/eval
Compiler.java: 7025 clojure.lang.Compiler/eval
core.clj: 3206 clojure.core/eval
core.clj: 3202 clojure.core/eval
main.clj: 243 clojure.main/repl/read-eval-print/fn
main.clj: 243 clojure.main/repl/read-eval-print
main.clj: 261 clojure.main/repl/fn
main.clj: 261 clojure.main/repl
main.clj: 177 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 142 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 834 java.lang.Thread/run
This is it
terrible
this is why I don't use nREPL
oh another bug in the code I wrote
https://github.com/vouch-opensource/krell/wiki/nREPL-Piggieback-Cider
Aha 🙂
@dnolen It’s working for me over here, thanks for the update
I can confirm that it works for me too! Thanks @dnolen
Working steps: Eval this in Emacs:
(setq cider-custom-cljs-repl-init-form
"(require '[<http://clojure.java.io|clojure.java.io> :as io]
'[clojure.edn :as edn]
'[cider.piggieback]
'[krell.api :as krell]
'[krell.repl])
(def config (edn/read-string (slurp (io/file \"build.edn\"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))")
M-x cider-jack-in-cljs
When prompted for the REPL type provide custom
.
The REPL will start and you’ll see user>
Start the simulator: react-native run-ios
.
Once the the connection is established, the REPL prompt will change to: cljs.user>
.@dotemacs Any idea if we can set the REPL type automatically to skip that step?
If by “automatically” you mean we write a custom .dir-locals.el
which will set that variable for us, then yes 🙂
But on the serious note, we should submit a patch that runs that step for us when it detects Krell.
Heh, I was already putting the cljs-repl-init form into .dir-locals.el
The same way it does it for the other tools, like for shadow-cljs…
🙂
Do you know which cider variable sets that repl type? I’m paging through the 8 million of them and not seeing anything off the top of my head.
I’m trying to find the place where it’s configured for other tools… digging around on GitHub right now…
Somewhere around here: https://github.com/clojure-emacs/cider/blob/master/cider.el#L325
@dotemacs I think here https://github.com/clojure-emacs/cider/blob/549982d205e1fea40010b9b121b1774bd6680e95/cider.el#L1302
glad it's working!
The way I see it, you can tell easily if a project is lein, boot, shadow-cljs… based, simply based on the config file: project.clj, boot…, deps.edn, shadow-cljs.edn. But for krell, I guess we have to see if it’s a dependency …
This is what I’m talking about: https://github.com/clojure-emacs/cider/blob/master/cider.el#L1478
Ah, I see. I was just looking to set the repl type to custom, this would skip that step entirely.
I get you. But I was hoping that there could be a “smart” step within CIDER that would figure out if it’s a Krell based project and then just inject the dependency. If it can’t figure it out, then it would revert to prompting the user…
Right.
I mean, you could rename build.edn
in your project to krell-build.edn
and look at that, but then you have to explain the difference to official docs.
I guess that could be an option.
But for now, I guess we could “suffer” this manual approach and see if that will be painful enough to warrant a PR…
Not sure
I’m going to commit the current setup to a blog post so it doesn’t get lost to the sands of Slack.
Nice 🙂
I created this issue to start a discussion: https://github.com/clojure-emacs/cider/issues/2841
Ok, instructions are here: https://increasinglyfunctional.com/2020/05/07/clojurescript-react-native-krell-emacs.html
thanks for writing that up
But it was @dnolen who did all the work, so all kudos to him 🙂
I’m just mentioning that in reference to your blog post @joshmiller because you gave me credit 🙂
Maybe you can amend it and also add cider-cljs-repl-type
set to custom
?
Tried that, no dice on skipping the repl type selection step.
@joshmiller this works, after adding it to .dir-locals.el
:
((nil . ((cider-default-cljs-repl . custom)
(cider-custom-cljs-repl-init-form . "(require '[<http://clojure.java.io|clojure.java.io> :as io]
'[clojure.edn :as edn]
'[cider.piggieback]
'[krell.api :as krell]
'[krell.repl])
(def config (edn/read-string (slurp (io/file \"build.edn\"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))"))))
you can just C-c M-J
. You won’t get prompted for anything.Oh cool, let me try that
That works, I’ll update.
I would love to hear if anyone has tips/scripts on making an iOS archive from a Krell app? It seems that re-natal has a complicated story based on leiningen for building publish-able archives. Unfortunately, the https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial#production-build tip hasn’t helped me; I haven’t seen a main.js being built and iOS archives result in an app waiting for the Krell repl socket.
ha I keep asking questions then fixing them myself shortly after. In case anyone has similar questions, this process seems to work:
clj -Srepro -m krell.main -v -co build.edn -O advanced -c
npx react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'
# finally, run standard build/archive process in XCode following <https://reactnative.dev/docs/running-on-device.html#building-your-app-for-production>
Thanks for sharing @adamtait