This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-07
Channels
- # announcements (11)
- # architecture (2)
- # babashka (84)
- # beginners (226)
- # calva (7)
- # chlorine-clover (4)
- # cider (29)
- # clara (17)
- # clj-kondo (23)
- # cljs-dev (58)
- # cljsrn (60)
- # clojure (172)
- # clojure-europe (24)
- # clojure-finland (2)
- # clojure-italy (6)
- # clojure-nl (8)
- # clojure-spec (4)
- # clojure-uk (22)
- # clojurescript (44)
- # conjure (39)
- # core-async (64)
- # cursive (76)
- # data-science (15)
- # duct (3)
- # emacs (2)
- # events (5)
- # fulcro (30)
- # helix (4)
- # jackdaw (5)
- # juxt (1)
- # kaocha (1)
- # leiningen (4)
- # off-topic (9)
- # pathom (22)
- # re-frame (9)
- # reagent (33)
- # reitit (3)
- # ring (10)
- # ring-swagger (2)
- # shadow-cljs (192)
- # spacemacs (27)
- # specter (2)
- # sql (59)
- # vim (2)
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.
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
The first thing that is missing is '[
in the :require
clause, as io
is used.
This is what happens. I eval this in Emacs:
(setq cider-custom-cljs-repl-init-form
"(require '[cider.piggieback]
'[ :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 for further details.
nil#'user/configFileNotFoundException {:main awesome-project.core
:output-to "target/main.js"
:output-dir "target"}
(No such file or directory) .FileInputStream.open0 (FileInputStream.java:-2)
IllegalArgumentException Don't know how to create ISeq from: java.lang.Character clojure.lang.RT.seqFrom (RT.java:550)
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
@dnolen It’s working for me over here, thanks for the update
Working steps: Eval this in Emacs:
(setq cider-custom-cljs-repl-init-form
"(require '[ :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
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
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.
But for now, I guess we could “suffer” this manual approach and see if that will be painful enough to warrant a PR…
I’m going to commit the current setup to a blog post so it doesn’t get lost to the sands of Slack.
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
I’m just mentioning that in reference to your blog post @joshmiller because you gave me credit 🙂
@joshmiller this works, after adding it to .dir-locals.el
:
((nil . ((cider-default-cljs-repl . custom)
(cider-custom-cljs-repl-init-form . "(require '[ :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
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
Thanks for sharing @adamtait