Thanks @zackteo, I would have thought so too, but that's kind of par for the course with Clojure documentation...
I'm trying it out with the exact examples from https://docs.cider.mx/cider/debugging/enlighten.html with no luck. Emacs tells me "Cider-Enlighten mode enabled", but evaluating the examples doesn't display the values in the buffer. Simply nothing happens.
If this is the case, hopefully CIDER docs can make it more clear which features do and don't work on CLJS?
Or perhaps I'm misreading the docs, it is implied https://docs.cider.mx/cider/debugging/debugger.html that "The debugger currently does not support ClojureScript", and perhaps that means that everything under the debugging section (including macroexpansion and tracing) doesn't support CLJS.
It would probably be nice for each feature page to have a little note like https://docs.cider.mx/cider/debugging/profiling.html to make it crystal clear to users what does and doesn't work in ClojureScript.
All that being said, I'd give an arm and a leg for all these features to support ClojureScript, that's where all my dev time is spent.
Unfortunately, bozhidar personally doesn't really use cljs so development on that end is tougher?
Am trying to figure out some CLJS CIDER stuff at the moment too 😅
Anyone here uses CIDER for cljs? I can't seem to get the CIDER jack-in-cljs to work? Any tips for doing so? 😮
cljs has more moving parts. can you describe your project? figwheel, figwheel main, shadow, deps.main?
what issue are you seeing besides it not working?
Was trying the reagent template - https://github.com/reagent-project/reagent-template after adding +shadow-cljs and +cider , am I can lauch it separately from the command line but can't quite seem to understand how I would launch it with shadow with `cider-jack-in`
let me try it out again another time first ...
i did lein new reagent check
and then cider-jack-in
. once the repl is up, (ns-publics *ns*)
showed that start-server
was defined so i gave that a shot and that got the backend up. then cider-jack-in-cljs
, choose figwheel and reload the webpage and i was up. i'm not sure what +cider
is doing but i just omitted it and all is grand
that puts an ancient version of cider in there. just ignore that option and things will work just fine
Sorry how does (ns-publics *ns*)
work? I often have trouble figuring out which options to pick for when doing a cider-cljs-jack-in
that's a clojure function that shows you the public vars in a namespace
okay but yes, have got it running (Not sure why i couldn't previously) hmmm
Like just by running cljs.user> (ns-publics *ns*)
?
cider-jack-in-cljs has many options because there are many optionsin the cljs tool space unfortunately. the first you need to choose is which build tool you are using. this template uses figwheel so choose that. and you should be done
i did that call in the clojure repl (not the cljs repl like you are doing). when the repl starts, the webserver isn't started yet. i was hoping (and was correct) that there would be a handy function to crank up the webserver
so even tho I picked the +shadow option I should still run it with figwheel? Think I am confusing 2 different things unfortunately
check.repl> (ns-publics *ns*)
{stop-server #'check.repl/stop-server,
start-server #'check.repl/start-server,
server #'check.repl/server,
get-handler #'check.repl/get-handler}
don't pick the shadow option. this template doesn't use shadow. pick figwheel
wait, you mean on the command line when you created it from the template?
yep!
lein new reagent <name> +shadow-cljs
that's not a valid option it seems. where did you enter +shadow
?
ah. then yes. start your backend up. then cider-jack-in-cljs
, choose shadow. then shadow needs to know which build you want. it should offer you a list of known builds
looks like app
is what you want
so you usually run cider-jack-in-clj
for the backend first then cider-jack-in-cljs
? 😮
yes
on a project with both a backend and a frontend like this
rightt, then how would you determine which command should be used
lein vs shadow-cljs
you chose shadow-cljs. it emitted a shadow-cljs.edn file which controls how the executable shadow-cljs
spins up the cljs compiler. CIDER is merely asking you which build tools are involved so it knows how to start up the right programs. shadow is a stand alone thing.
and shadow is exclusively cljs. so for the backend you just start up lein (and notice you didn't get a choice when cider-jack-in
). for the frontend you're telling it to use shadow and then it has one last question about which build to use
Do I connect the clj and cljs repl as siblings then?
yes
that kinda just means "same project"
cider-jack-in-clj&cljs
does the same right?
not exactly. it uses the same jvm i think and that's not possible here where the backend is a lein project and the frontend is a shadow project
Okay that might have been the issue i was having then whoops :x
i think that uses the same jvm and gives you two repls, the second of which just starts up the cljs compiler. at the top of the repl are the startup commands which might help explain things
;; Startup: /Users/dan/bin/lein update-in :dependencies conj \[nrepl\ \"0.8.0\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.1\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.3\"\] -- repl :headless :host localhost
;;
;; ClojureScript REPL type: figwheel
;; ClojureScript REPL init form: (do (require 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/start-figwheel!) (figwheel-sidecar.repl-api/cljs-repl))
the first command is how the repl started up lein ... repl
essentially. the second is how it started the cljs compiler for you. (start-figwheel!) (cljs-repl)
in essence
that's not possible when shadow is a separate executable and process
but if i were to use figwheel
it would have been okay?
i think so. let me check
Thanks so much for your help!! Oddly enough tooling is what's getting me stuck ><
works for me
the tooling can be difficult. CIDER really tries to show you exactly what is going on with those startup commands. so that you can always read the documentation of the underlying tool to know what problems you might be hitting
but hopefully you're on your way now
right! I thought the shadow is the standard nowadays, which i why I try to avoid figwheel
perhaps am kinda wrong to think that
figwheel is outdated but still pays the bills for lots of projects. bruce rewrote it as figwheel-main for a modern flair. i'm quite partial to shadow for its fantastic interop with npm packages. it does a lot of really nice stuff. the build report is also quite nice. there are some UI tools for inspecting things as well
the two main contenders are shadow-cljs and figwheel-main. if you're up and running with shadow i'd just carry on with that and get back to cranking out cool ideas
quick question. How and do you transition from cljs.user
to shadow.user
and back (like in terms of your workflow
i don't know what shadow.user is. but i would just be in whatever namespace i needed to be in for my code
C-c C-k
will evaluate namespaces and C-c M-n n
will switch the repl to that namespace. you can also use (require 'my.ns)
and then (in-ns 'my-ns)
to change the repl namespace as well
https://clojure.org/guides/repl/introduction has good info i believe
Right! Thanks so much! 😄
C-cM-n n works for cljs/ clj and cljc ?
I’m afraid it’d be quite complex to support some of the Clojure features on ClojureScript, otherwise we would have done this by now. 🙂 Feel free to open a ticket about the documentation and I’ll update it when I can. If I recall correct enlighten is implemented in terms of the debugger which means it’s definitely Clojure-only for now.
Yeah, that’s true. Still, haven’t gotten to mastering cljs. 🙂
It should. After all it simply evals in-ns
.
Cider worked just fine on Emacs 26.3 for the last year and a half. I was also using CIDER on Emacs 27 (before and after its release as the new stable version). I am now running CIDER daily on Emacs 28. I would avoid using Emacs 25.1 (although I am fairly certain CIDER would work fine) as there are issues with the package repository authentication and its two releases behind now
In particular my issue is: Running cider-test-run-ns-tests
results in a cons: Symbol's function definition is void: first
error. I don't see anything in github issues about this.
as you can see in that thread, ag said first
is a function that doesn't exist in "older versiond of emacs"
When moving to Emacs 27 I've deleted quite a few Emacs packages and restarted Emacs to download fresh copies. This seems to fix issues with Emacs not finding things. Its a quick brute force fix and I just had to do that with Magit today. It doesnt explain the underlying issue, but so far its worked. Not had your issue with CIDER though, so no guarantee.
Ok, I upgraded to Emacs 27. That didn't fix it. cons: Symbol's function definition is void: first
still when running cider-test-run-ns-tests
@ramblurr can you provide a stacktrace in Emacs. You could try to M-x toggle-debug-on-error
and then reproduce the problem. Maybe that tells us more where the problem is coming from.
I didnt think Emacs versions was the issue, appologies if I gave that impression. Did you delete all CIDER related packages from ~/.emacs.d/elpa/
?
Have you run Cider test runner before or is this the first time?
Have you used a test runner on the command line?
To narrow down an issue, its useful to know if the project runs or tests run on the command line.
If you are using leingingen and lein test
gives a similar error, then is seems its a bug in the project
{:a {:a 1}
:b {:b 2}}
and
{:c {:c 3}
:d {:d 4}}
=>
{:a {:a 1}
:b {:b 2}
:c {:c 3}
:d {:d 4}}
How is this achieved? Conj, concat and merge seems to just put them into a list together
Merge should do the trick, right?
Yes, merge works
(merge {:a {:a 1}
:b {:b 2}}
{:c {:c 3}
:d {:d 4}})
#beginners is a better channel for help on general Clojure topics, a lot more people in that channel generally.
I realized I was being stupid, my maps were inside a list all along
Thank you for the response!
Will keep that in mind next time, thanks 🙂
Easy to do. I use rainbow parens with CIDER to help show the structure of the code
This was from the repl, which doesn't have any highlighting at all. never looked into it, but do you know if it's possible to enable rainbow parens in there? 😄
Would be fantastic
Just enabling it worked, cool.
If you use Spacemacs (a community config for Emacs), there is also the #spacemacs channel. Otherwise any CIDER related questions should get an answer here.
Ah nice, this Slack seems to have it all! 🙂
cider-jack-in question: is there a way to configure the jack-in command line to not include the -Sdeps
part? (the deps that are auto-injected to make it work)
I appreciate I can use the universal argument to edit the command each time...
I have a Clojure CLI alias that runs REBL repl with nREPL and I can successfully connect with cider-connect-clj
but when using cider-jack-in-clj
and a .dir-locals.el
file to set the alias, something in the -Sdeps
section of the command line is conflicting.
I guess I should really figure out the conflict (but that may take a while).
I can confirm that cider-test-run-ns-test
runs in vanilla Emacs 26.3 (Debian GNU/Linux Stretch), using CIDER 0.25.0 (Bergamo). I use it regularly and just checked it a few seconds ago.
i think you can set cider-inject-dependencies-at-jack-in
to nil and it might then work?
There are lots of other ways to get help too.. here is a quick guide to them https://practicalli.github.io/blog/posts/cloure-community-getting-help/
Adding that config to .dir-locals.el
seems to kill the aliases I add too, unless I have got the config wrong
((clojure-mode . ((cider-inject-dependencies-at-jack-in . nil)
(cider-clojure-cli-global-options . "-R:nrepl:cider-nrepl:cognitect-rebl -A:nrebl"))))
With that .dir-locals.el file cider-jack-in uses the command line:
[nREPL] Starting server via /usr/local/bin/clojure -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'
and of course that goes bang because there is no nrepl 🙂
maybe you want cider-jack-in-nrepl-middlewares
then?
oh i'm not sure and its too early for me. but i suspect you'll have to walk through cider--update-jack-in-cmd
and see where the different parts get added. you may need to add a new keyword to the params
that are threaded through? or maybe the easiest way is to add a way to just give it an absolute command. there's no real reason it has to be dynamic if you are calling just a known string
If I can set an absolute command for cider-jack-in-clj using .dir-locals.el
that would work just fine.
:jack-in-cmd
is the params key. maybe update the logic to not override this if its already present?
(defun practicalli/REBL () (interactive) (cider-jack-in :jack-in-cmd "clj stuff"))
• lein test
works
• cider-run-test
works on individual tests
• I have used cider test runner before • I have used the cli runner • And yea, I purged and re downloaded my elpa packages
Hmm, I thought I could be clever and use something like that in the .dir-locals.el
file, but it didnt work.
((clojure-mode . ((eval . (progn
(cider-jack-in-cljs :jack-in-cmd "/usr/local/bin/clojure -R:nrepl:cider-nrepl:cognitect-rebl -A:nrebl"))))))
I'll try it just in the init.el file.yes there's no logic to conditional set :jack-in-cmd
you would need to extend it i think
Ah this is getting complicated, sounds like something for the weekend. Thanks for all the pointers though... I can live with cider-connect for now 🙂
Thank you, that is a much nicer approach.
I started looking at adding a clojure-rebl
project type, but didn't get it working (it seems I still have a great deal to understand about the CIDER code). Thanks again.
I am at a loss of other ideas. If its not specific to the Clojure project itself then I dont know what to suggest, sorry.