This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-01
Channels
- # adventofcode (93)
- # announcements (44)
- # asami (23)
- # aws (1)
- # babashka (48)
- # beginners (112)
- # calva (26)
- # cider (57)
- # clj-kondo (17)
- # cljfx (5)
- # cljs-dev (21)
- # clojure (124)
- # clojure-europe (19)
- # clojure-hungary (40)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (3)
- # clojurescript (3)
- # cursive (81)
- # datalog (11)
- # events (21)
- # exercism (1)
- # fulcro (37)
- # graalvm (1)
- # introduce-yourself (8)
- # jobs (1)
- # lsp (1)
- # malli (5)
- # membrane-term (17)
- # minecraft (3)
- # nextjournal (5)
- # off-topic (14)
- # other-lisps (14)
- # polylith (58)
- # reagent (16)
- # reclojure (3)
- # reitit (6)
- # remote-jobs (1)
- # shadow-cljs (55)
- # spacemacs (15)
- # testing (2)
- # tools-build (7)
- # tools-deps (191)
I’ve finally decided that I can’t rely on a console repl for ClojureScript on node anymore, and I’m trying to use Cider, since that’s what I use with Clojure. Unfortunately, I haven’t been able to make it work. I’ve added cider/piggieback to my deps.edn, and added the recommended alias:
:aliases {:cider-cljs {:main-opts ["-m" "nrepl.cmdline" "--middleware"
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}
Then when I use M-x
cider-jack-in-cljs I give my desired repl as node
This responds with a banner, and finishes with:
;; Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/piggieback {:mvn/version "0.5.2"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}' -M:cider/nrepl
;;
;; ClojureScript REPL type: node
;; ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
;;
user>
So I type: (+ 2 3)
to see if it works, and I get:
TypeError: Cannot read property 'error__GT_str' of undefined
at Socket.<anonymous> ([stdin]:89:28)
at Socket.emit (events.js:400:28)
at Socket.emit (domain.js:470:12)
at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:261:11)
at Socket.Readable.push (internal/streams/readable.js:204:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
at TCP.callbackTrampoline (internal/async_hooks.js:131:17)
So now I’m stuck. Any advice is welcome please.do you have to run the init form it suggets? (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
well, I’ve since discovered that I don’t have to type anything and I get that stack trace after a few seconds
right
I just tried anyway, because I really don’t know what I’m doing… but no, nothing happens.
The startup command:
Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/piggieback {:mvn/version "0.5.2"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}' -M:cider/nrepl
doesn’t seem to have the :cider-cljs
alias within itwhen you run cider-jack-in-cljs it won't run with the :cider-cljs alias you setup unless you add it to your dir locals file
in your project root you would add the file ".dir-locals.el"
((clojurescript-mode
(cider-clojure-cli-aliases . "-A:cider-cljs")
)))
docs: https://docs.cider.mx/cider/config/project_config.htmlI think, i manage to always F it up though 😢
FWIW, i don't know if that will fix things. I always start clojure script through shadow
;; Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/piggieback {:mvn/version "0.5.2"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}' -M:cider-cljs:cider/nrepl
;;
;; ClojureScript REPL type: node
;; ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
looks like the command was updated, but not the aliases. I don’t know how they get updated?
[stands up on a desk] My name is drew verlee. i have been doing cljs development for like 3 years on and off, i have no idea how to get a cljs repl running correctly without shadow or figwheel.
i await someone to be along shortly and show me a one line of code to do it.
I started setting up shadow on a test project earlier, but hadn’t actually done anything with it. I just tried it now. Worked perfectly
maybe to clarify how things work in shadow-cljs. shadow-cljs itself is written in Clojure so the default REPL you start out with is CLJ. From there you can control shadow-cljs itself, all via CLJ. One thing you can do is select/switch your CLJ REPL to a CLJS REPL. either that is coupled to a build or not
from the command line for example you can do shadow-cljs clj-repl
which connects you do the CLJ REPL. in there you can run (shadow/node-repl)
which will switch that REPL to CLJS running in node
that is basically what you need cider to do. Can't tell you how but I believe you got it to work in the end
so the "can't load namepaces" likely means you are still in a CLJ REPL that needs to be switched
shadow-cljs clj-repl
(shadow/watch :my-build)
same as shadow-cljs watch my-build
only that you still have a open REPL connection to do more (eg. start another build, stop it, etc)
It was my mistake… I was running emacs in the wrong project. It contained identical files, so I hadn’t realized that I was in the wrong place. Very embarrassing 😳
C-c C-k says that it’s loading the file, but then it just sits there. If I look at any symbols (it’s test file with a single defn in it) then they’re not defined
I started by repl via cljs-jack-in-cljs
selected my shadow config and the app rendered without error in my browser. I have my nrepl server buffer running telling me nrepl is on a port, and i havea repl buffer where i can type in commands.
However, cider eval last sexp does nothing and if tell cider to quit it tells me "no repls in the current session"
it doesnt
it says my repl is connected. it's like it goes through all the steps but doesn't establish the connection
weird. is it possible you’ve navigated to a dependency or something? It sounds like everything is working but it doesn’t recognize the source buffer as being in the project that is connected to the repl
err, ugh. i just had a half formed thought. I know why its happening in a vague way.
It's on my end, not emacs or cider, but how the project is setup.
there’s something like sesman link directory
or equivalents that should hopefully help you correct all that
@dpsutton i think the namespaces are excluded in the compilation step. We have feature flags. When i switched to a different ns everything worked.