Fork me on GitHub
#cider
<
2020-08-28
>
neilyio00:08:29

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

neilyio01:08:32

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.

neilyio01:08:53

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

neilyio01:08:25

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.

neilyio01:08:25

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.

neilyio01:08:22

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.

bozhidar06:08:37

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.

zackteo01:08:02

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

bozhidar06:08:22

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

zackteo01:08:26

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

zackteo05:08:05

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

dpsutton05:08:32

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

dpsutton05:08:50

what issue are you seeing besides it not working?

zackteo05:08:32

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`

zackteo05:08:46

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

dpsutton05:08:28

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

dpsutton05:08:02

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

zackteo05:08:18

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

dpsutton05:08:08

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

zackteo05:08:21

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

zackteo05:08:21

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

dpsutton05:08:29

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

dpsutton05:08:08

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

zackteo05:08:35

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

dpsutton05:08:45

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}

dpsutton05:08:59

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

dpsutton05:08:33

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

zackteo05:08:59

yep!

lein new reagent <name> +shadow-cljs

dpsutton05:08:00

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

dpsutton05:08:55

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

dpsutton05:08:07

looks like app is what you want

zackteo05:08:23

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

dpsutton05:08:44

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

zackteo05:08:23

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

dpsutton05:08:36

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.

dpsutton05:08:45

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

zackteo05:08:21

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

dpsutton05:08:33

that kinda just means "same project"

zackteo05:08:33

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

dpsutton05:08:02

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

zackteo05:08:28

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

dpsutton05:08:32

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

dpsutton05:08:26

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

dpsutton05:08:45

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

zackteo05:08:36

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

dpsutton05:08:47

i think so. let me check

zackteo05:08:20

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

dpsutton05:08:38

works for me

dpsutton05:08:09

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

dpsutton05:08:15

but hopefully you're on your way now

zackteo05:08:41

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

dpsutton06:08:55

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

dpsutton06:08:37

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

zackteo06:08:43

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

dpsutton06:08:06

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

dpsutton06:08:15

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

zackteo06:08:10

Right! Thanks so much! 😄

zackteo06:08:27

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

bozhidar06:08:02

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

practicalli-johnny09:08:01

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

Casey09:08:06

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-johnny09:08:25

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.

Casey10:08:18

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

practicalli-johnny11:08:22

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-johnny11:08:14

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

iarenaza12:08:09

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.

Casey13:08:45

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

Casey13:08:46

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

practicalli-johnny15:08:36

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.

ska10:08:25

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

Risetto12:08:15

{: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}}

practicalli-johnny12:08:31

Yes, merge works

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

practicalli-johnny12:08:16

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

Risetto12:08:26

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

Risetto12:08:32

Thank you for the response!

Risetto12:08:51

Will keep that in mind next time, thanks 🙂

practicalli-johnny12:08:34

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

Risetto12:08:44

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

Risetto12:08:53

Would be fantastic

Risetto12:08:49

Just enabling it worked, cool.

👍 3
practicalli-johnny12:08:05

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.

Risetto12:08:32

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

practicalli-johnny13:08:08

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/

Risetto12:08:56

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

Risetto12:08:29

Merge should do the trick, right?

practicalli-johnny12:08:38

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

dpsutton13:08:23

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

practicalli-johnny13:08:20

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-johnny13:08:54

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-johnny13:08:18

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

dpsutton13:08:00

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

dpsutton13:08:39

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-johnny13:08:46

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

dpsutton13:08:47

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

practicalli-johnny13:08:02

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.

dpsutton13:08:59

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

practicalli-johnny13:08:42

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 🙂

iarenaza16:08:52

@jr0cket Now that I've seen in http://practicalli.github.io/clojure/clojure-tools/data-browsers/rebl-data-visualization.html#practicalli the exact command line you wanted for clj, this is the closer you can get in CIDER using .dir-locals.el without changing the code:

((clojure-mode . ((cider-preferred-build-tool . clojure-cli)
                  (cider-clojure-cli-global-options . "-R:nrepl:cider-nrepl:cognitect-rebl -A:nrebl")
                  (cider-jack-in-dependencies . nil)
                  (cider-jack-in-nrepl-middlewares . nil)
                  (cider-jack-in-lein-plugins . nil)
                  (cider-clojure-cli-parameters . ""))))

practicalli-johnny21:08:33

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.

iarenaza16:08:52

@jr0cket Now that I've seen in http://practicalli.github.io/clojure/clojure-tools/data-browsers/rebl-data-visualization.html#practicalli the exact command line you wanted for clj, this is the closer you can get in CIDER using .dir-locals.el without changing the code:

((clojure-mode . ((cider-preferred-build-tool . clojure-cli)
                  (cider-clojure-cli-global-options . "-R:nrepl:cider-nrepl:cognitect-rebl -A:nrebl")
                  (cider-jack-in-dependencies . nil)
                  (cider-jack-in-nrepl-middlewares . nil)
                  (cider-jack-in-lein-plugins . nil)
                  (cider-clojure-cli-parameters . ""))))