cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
neilyio 2020-08-28T00:59:29.039800Z

Thanks @zackteo, I would have thought so too, but that's kind of par for the course with Clojure documentation...

neilyio 2020-08-28T01:01:32.041400Z

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.

neilyio 2020-08-28T01:01:53.041900Z

If this is the case, hopefully CIDER docs can make it more clear which features do and don't work on CLJS?

neilyio 2020-08-28T01:05:25.043200Z

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.

neilyio 2020-08-28T01:06:25.044Z

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.

neilyio 2020-08-28T01:07:22.044900Z

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.

zackteo 2020-08-28T01:17:02.047200Z

Unfortunately, bozhidar personally doesn't really use cljs so development on that end is tougher?

zackteo 2020-08-28T01:17:26.047900Z

Am trying to figure out some CLJS CIDER stuff at the moment too 😅

zackteo 2020-08-28T05:19:05.049500Z

Anyone here uses CIDER for cljs? I can't seem to get the CIDER jack-in-cljs to work? Any tips for doing so? 😮

dpsutton 2020-08-28T05:24:32.050100Z

cljs has more moving parts. can you describe your project? figwheel, figwheel main, shadow, deps.main?

dpsutton 2020-08-28T05:24:50.050400Z

what issue are you seeing besides it not working?

zackteo 2020-08-28T05:31:32.051700Z

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`

zackteo 2020-08-28T05:31:46.052100Z

let me try it out again another time first ...

dpsutton 2020-08-28T05:37:28.053600Z

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

dpsutton 2020-08-28T05:39:02.054600Z

that puts an ancient version of cider in there. just ignore that option and things will work just fine

zackteo 2020-08-28T05:39:18.055Z

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

dpsutton 2020-08-28T05:40:08.056100Z

that's a clojure function that shows you the public vars in a namespace

zackteo 2020-08-28T05:40:21.056600Z

okay but yes, have got it running (Not sure why i couldn't previously) hmmm

zackteo 2020-08-28T05:41:21.057500Z

Like just by running cljs.user> (ns-publics *ns*) ?

dpsutton 2020-08-28T05:41:29.057700Z

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

dpsutton 2020-08-28T05:42:08.058900Z

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

zackteo 2020-08-28T05:42:35.059500Z

so even tho I picked the +shadow option I should still run it with figwheel? Think I am confusing 2 different things unfortunately

dpsutton 2020-08-28T05:42:45.059700Z

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}

dpsutton 2020-08-28T05:42:59.060100Z

don't pick the shadow option. this template doesn't use shadow. pick figwheel

dpsutton 2020-08-28T05:43:33.060600Z

wait, you mean on the command line when you created it from the template?

zackteo 2020-08-28T05:43:59.061100Z

yep!

lein new reagent <name> +shadow-cljs

dpsutton 2020-08-28T05:44:00.061200Z

that's not a valid option it seems. where did you enter +shadow?

dpsutton 2020-08-28T05:44:55.062Z

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

dpsutton 2020-08-28T05:45:07.062200Z

looks like app is what you want

zackteo 2020-08-28T05:46:23.063100Z

so you usually run cider-jack-in-clj for the backend first then cider-jack-in-cljs? 😮

dpsutton 2020-08-28T05:46:28.063300Z

yes

dpsutton 2020-08-28T05:46:44.063700Z

on a project with both a backend and a frontend like this

zackteo 2020-08-28T05:47:23.064600Z

rightt, then how would you determine which command should be used lein vs shadow-cljs

dpsutton 2020-08-28T05:48:36.065800Z

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.

dpsutton 2020-08-28T05:49:45.066800Z

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

zackteo 2020-08-28T05:51:21.067800Z

Do I connect the clj and cljs repl as siblings then?

dpsutton 2020-08-28T05:51:26.068Z

yes

dpsutton 2020-08-28T05:51:33.068300Z

that kinda just means "same project"

zackteo 2020-08-28T05:52:33.069100Z

cider-jack-in-clj&cljs does the same right?

dpsutton 2020-08-28T05:53:02.069700Z

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

zackteo 2020-08-28T05:54:28.070900Z

Okay that might have been the issue i was having then whoops :x

dpsutton 2020-08-28T05:54:32.071100Z

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

dpsutton 2020-08-28T05:55:26.072200Z

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

dpsutton 2020-08-28T05:55:45.072500Z

that's not possible when shadow is a separate executable and process

zackteo 2020-08-28T05:56:36.073Z

but if i were to use figwheel it would have been okay?

dpsutton 2020-08-28T05:56:47.073200Z

i think so. let me check

zackteo 2020-08-28T05:58:20.074Z

Thanks so much for your help!! Oddly enough tooling is what's getting me stuck ><

dpsutton 2020-08-28T05:58:38.074200Z

works for me

dpsutton 2020-08-28T05:59:09.075300Z

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

dpsutton 2020-08-28T05:59:15.075600Z

but hopefully you're on your way now

zackteo 2020-08-28T05:59:41.076200Z

right! I thought the shadow is the standard nowadays, which i why I try to avoid figwheel perhaps am kinda wrong to think that

dpsutton 2020-08-28T06:00:55.077500Z

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

dpsutton 2020-08-28T06:01:37.078300Z

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

zackteo 2020-08-28T06:03:43.079300Z

quick question. How and do you transition from cljs.user to shadow.user and back (like in terms of your workflow

dpsutton 2020-08-28T06:04:06.079800Z

i don't know what shadow.user is. but i would just be in whatever namespace i needed to be in for my code

dpsutton 2020-08-28T06:05:15.081Z

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

dpsutton 2020-08-28T06:05:37.081200Z

https://clojure.org/guides/repl/introduction has good info i believe

zackteo 2020-08-28T06:08:10.081700Z

Right! Thanks so much! 😄

zackteo 2020-08-28T06:08:27.082100Z

C-cM-n n works for cljs/ clj and cljc ?

bozhidar 2020-08-28T06:31:37.082200Z

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.

bozhidar 2020-08-28T06:32:22.082400Z

Yeah, that’s true. Still, haven’t gotten to mastering cljs. 🙂

bozhidar 2020-08-28T06:36:02.083Z

It should. After all it simply evals in-ns.

practicalli-john 2020-08-28T09:22:01.086600Z

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

Casey 2020-08-28T09:31:06.087200Z

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"

practicalli-john 2020-08-28T09:35:25.090500Z

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.

Casey 2020-08-28T10:25:18.091600Z

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

ska 2020-08-31T10:29:25.016100Z

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

practicalli-john 2020-08-28T11:25:22.092Z

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.

practicalli-john 2020-08-28T11:27:14.092200Z

If you are using leingingen and lein test gives a similar error, then is seems its a bug in the project

Risetto 2020-08-28T12:27:15.092900Z

{:a {:a 1}
 :b {:b 2}}
and
{:c {:c 3}
 :d {:d 4}}
=&gt;
{:a {:a 1}
 :b {:b 2}
 :c {:c 3}
 :d {:d 4}}

Risetto 2020-08-28T12:27:56.093800Z

How is this achieved? Conj, concat and merge seems to just put them into a list together

Risetto 2020-08-28T12:30:29.094300Z

Merge should do the trick, right?

practicalli-john 2020-08-28T12:34:31.094400Z

Yes, merge works

(merge  {:a {:a 1}
         :b {:b 2}}
        {:c {:c 3}
         :d {:d 4}})

practicalli-john 2020-08-28T12:35:16.094600Z

#beginners is a better channel for help on general Clojure topics, a lot more people in that channel generally.

Risetto 2020-08-28T12:35:26.094800Z

I realized I was being stupid, my maps were inside a list all along

Risetto 2020-08-28T12:35:32.095Z

Thank you for the response!

Risetto 2020-08-28T12:35:51.095200Z

Will keep that in mind next time, thanks 🙂

practicalli-john 2020-08-28T12:36:34.095500Z

Easy to do. I use rainbow parens with CIDER to help show the structure of the code

Risetto 2020-08-28T12:37:44.095700Z

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? 😄

Risetto 2020-08-28T12:37:53.095900Z

Would be fantastic

Risetto 2020-08-28T12:38:49.096100Z

Just enabling it worked, cool.

👍 1
practicalli-john 2020-08-28T12:40:05.096400Z

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.

Risetto 2020-08-28T12:42:32.096600Z

Ah nice, this Slack seems to have it all! 🙂

practicalli-john 2020-08-28T12:56:38.102700Z

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

iarenaza 2020-08-28T12:59:09.102800Z

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.

dpsutton 2020-08-28T13:02:23.103200Z

i think you can set cider-inject-dependencies-at-jack-in to nil and it might then work?

practicalli-john 2020-08-28T13:03:08.103300Z

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/

practicalli-john 2020-08-28T13:07:20.104900Z

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

practicalli-john 2020-08-28T13:08:54.105900Z

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"]'

practicalli-john 2020-08-28T13:09:18.106300Z

and of course that goes bang because there is no nrepl 🙂

dpsutton 2020-08-28T13:11:00.106500Z

maybe you want cider-jack-in-nrepl-middlewares then?

dpsutton 2020-08-28T13:12:39.107900Z

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

practicalli-john 2020-08-28T13:13:46.109Z

If I can set an absolute command for cider-jack-in-clj using .dir-locals.el that would work just fine.

dpsutton 2020-08-28T13:14:47.110300Z

: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"))

Casey 2020-08-28T13:24:45.110600Z

lein test works • cider-run-test works on individual tests

Casey 2020-08-28T13:25:46.111600Z

• I have used cider test runner before • I have used the cli runner • And yea, I purged and re downloaded my elpa packages

practicalli-john 2020-08-28T13:30:02.112400Z

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.

dpsutton 2020-08-28T13:32:59.112900Z

yes there's no logic to conditional set :jack-in-cmd you would need to extend it i think

practicalli-john 2020-08-28T13:33:42.113800Z

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 🙂

practicalli-john 2020-08-30T21:56:33.009300Z

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.

practicalli-john 2020-08-28T15:05:36.113900Z

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.