Fork me on GitHub
#cider
<
2019-06-26
>
oskarkv01:06:17

Hm, functions don't font lock dynamically correctly in cljs for me. I rememer that I worked on this like 2 years ago. I wanted to try and see if I can debug and fix it. But now my mind is blank as to how this all worked, with cider-nrepl mostly. How do I most conveniently send input to cider-nrepl and how do I see the output? I want to for example test the function cider.nrepl.middleware.track-state/ns-as-map for a cljs namespace. How would I do that?

dpsutton01:06:01

the simplest path to some message introspection is nrepl-toggle-message-logging so you can see what CIDER sends back and forth. Anything beyond that gets a little hairy

oskarkv01:06:21

@dpsutton Ok! But if I have jacked-in to the cider-nrepl project, which is clj, then how do I test it for cljs?

dpsutton01:06:05

i don't know how to answer that. I've traced some of that stuff before and its a tower :0

felipebarros02:06:59

I'm getting this while trying to connect to an nrepl using cider-connect after following the instructions here (https://github.com/nrepl/piggieback#clojure-cli-aka-toolsdeps), but the link for More information is broken.

WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!
         More information.

felipebarros02:06:06

What I'm really trying to do is to connect Cider to a figwheel-main project using deps.cli using this figwheel-main template https://rigsomelight.com/figwheel-main-template/

felipebarros02:06:11

If I follow the docs https://docs.cider.mx/cider/basics/clojurescript.html#_using_figwheel_main I get error in process filter: Figwheel-main is not available. Please check which is the place I'm coming from.

oskarkv05:06:29

@anantpaatra Are you using deps.edn?

oskarkv05:06:50

Oh, yeah, you said

felipebarros05:06:39

Have you been able to connect Cider to it? This is my current struggle.

felipebarros05:06:44

Can you tell me more or less how to connect? I don't see specific instructions on that tutorial. I've been using that exact configuration through the figwheel-main template without luck.

oskarkv06:06:35

cider-jack-in-cljs, choose figwheel-main, then choose your, eh, like build name

oskarkv06:06:34

If you do jack-in, do you get a list of different tools to choose from?

felipebarros07:06:19

Just tried it again following that tutorial by hand, and when I cider-jack-in-cljs I still get that error in process filter: Figwheel-main is not available. Please check error. 😞

oskarkv05:06:53

Hm, I'm hacking on cider-nrepl, and I'm running tests. If I run all tests, I get an error that I don't get when I run only that files' test, and vice versa. This is with make test

lein test cider.nrepl.middleware.track-state-test

lein test :only cider.nrepl.middleware.track-state-test/ns-as-map-cljs-test

FAIL in (ns-as-map-cljs-test) (track_state_test.clj:132)
expected: {sym-0 {:arglists ([]), :macro true}, sym-1 {:arglists ([])}, a-var {}, a-fn {:fn "true"}, b-fn {:fn "true"}, c-fn {:fn "true"}}
  actual: ({a-fn {:fn "true"}, b-fn {}, c-fn {}, a-var {}, sym-1 {:arglists ([])}, sym-0 {:arglists ([]), :macro true}})
And this is with lein test cider.nrepl.middleware.track-state-test
lein test cider.nrepl.middleware.track-state-test

lein test :only cider.nrepl.middleware.track-state-test/update-and-send-cache-test

FAIL in (update-and-send-cache-test) (track_state_test.clj:38)
expected: (< 100 (count new-data))
  actual: (not (< 100 74))

lein test :only cider.nrepl.middleware.track-state-test/update-and-send-cache-test

FAIL in (update-and-send-cache-test) (track_state_test.clj:42)
expected: (< 100 (count changed-namespaces))
  actual: (not (< 100 73))
I had an error in ns-as-map-cljs-test at first, when running just that file. But then I fixed it, and I'm pretty sure it's right now. So why do I get the error when running with make test? The output I could see in actual was different, even when it was wrong in both.

dpsutton11:06:36

https://github.com/clojure-emacs/cider-nrepl/issues/390 The track state bug happens because we are using the thing under test in the tests. Running all tests loads more namespaces than just running an individual file.

oskarkv05:06:57

Also, I haven't touched update-and-send-cache so it shouldn't be failing, I reckon. 😕

oskarkv06:06:17

And when running from CIDER I get 0 errors

(run-tests *ns*)

Testing cider.nrepl.middleware.track-state-test

Ran 7 tests containing 34 assertions.
0 failures, 0 errors.
{:test 7, :pass 34, :fail 0, :error 0, :type :summary}

bozhidar08:06:16

@anantpaatra The check that’s failing for you is pretty basic:

bozhidar08:06:19

(defun cider-check-figwheel-main-requirements ()
  "Check whether we can start a Figwheel ClojureScript REPL."
  (cider-verify-piggieback-is-present)
  (unless (cider-library-present-p "figwheel.main")
    (user-error "Figwheel-main is not available.  Please check )))

bozhidar08:06:50

If it’s failing that would indicate the figwheel.main ns seems to be missing.

bozhidar08:06:40

You can try suppressing the requirements check by setting cider-check-cljs-repl-requirements to nil, but if figwheel-main is truly missing that won’t help you much. 🙂

felipebarros08:06:06

After many hours I have just found https://github.com/clojure-emacs/cider/issues/2597 and managed to fix it by setting cider-clojure-cli-global-options to -R:fig because it was in an alias (I don't know why I thought it would pick this up magically). Now that I have understood what was wrong it seems basic but do you think its the case to document this nuance of using tools.deps with cider somewhere? Others may fall into this trap. Thanks 🙂

felipebarros08:06:31

It's not mentioned in the README for the figwheel template (maybe I could suggest that) or in the figwheel tutorial and even the cider docs (at least I couldn't find it).

felipebarros08:06:26

This composition of aliases is a fairly new concept that isn't contemplated in many tutorials. Sean Corfield has a new screencast that was pretty enlightening to me and I believe may even be linked somewhere in the docs.

bozhidar08:06:31

> Now that I have understood what was wrong it seems basic but do you think its the case to document this nuance of using tools.deps with cider somewhere? Others may fall into this trap. Thanks 🙂

bozhidar08:06:06

@anantpaatra yeah, I guess we should. I was under the impression most people just put figwheel.main in their main deps.

bozhidar08:06:51

There are several way to approach this, btw - we can also put the clojurescript deps in cider-jack-in-cljs. That’s not hard to do, but then people will have to know that cider might be injecting different versions of the deps overriding what they have in their projects.

bozhidar08:06:03

Too much flexibility means you have to think of many details. 🙂

felipebarros08:06:48

Maybe when the user selects figwheel-main during cider-jack-in-cljs it could test to see if it is available? Hmm, maybe not. That could hide a problem in the user configuration or usage. Perhaps just updating the error message to state something like "figwheel.main wasn't found. If you're not declaring it as a main dependency, make sure you're passing it with -R:<alias>".

bozhidar08:06:16

@anantpaatra The checks happens at a point where you don’t know how the REPL was started exactly, that’s why we check for the presence of the namespace only.

bozhidar08:06:36

A sophisticated check is way too involved as we have to take into account many nuances for each build tool and I have think there are more important areas of improvements we can focus on. 🙂

bozhidar09:06:03

I think for now just adding something in the docs about tools.deps would be helpful for most people.

felipebarros09:06:59

I understand and agree 🙂

oskarkv09:06:32

@bozhidar You don't happen to know what's up with the inconsistencies with the tests I described above?

bozhidar09:06:36

@oskarkv Yeah, I do.

bozhidar09:06:18

lein test is not very useful with cider-nrepl as I don’t think it gets bound to meaningful profile. I think we don’t have anything in the dev profile.

bozhidar09:06:10

make test is running the tests using a build with inlined deps and finally what you would run straight from CIDER is a build using whatever is currently loaded.

oskarkv09:06:04

I'm not sure I understand the difference. Which should I go by?

bozhidar09:06:54

Generally the results from make test and running tests within CIDER should be consistent unless you ended up using something that gets inlined in the tests (this would pass in CIDER and fail otherwise).

bozhidar09:06:57

To run tests with Lein you need to do something like:

bozhidar09:06:09

lein with-profile +1.8,+test,+plugin.mranderson/config test

bozhidar09:06:55

Well, you shouldn’t use lein test without specifying some profiles. 🙂

bozhidar09:06:24

Generally while I develop cider-nrepl are run the tests from within CIDER and I just confirm in the end with make test that everything’s ok.

bozhidar09:06:33

Unfortunately inlining deps and the need to support several Clojure and ClojureScript releases makes something that’s typically simple quite complex…

oskarkv09:06:19

Hm, I'll have to continue tomorrow. Too tired for now. Thanks!

oskarkv09:06:53

Btw, why are the tests using 1.8, and not 1.10? 😛

oskarkv09:06:12

Oh, no, they aren't.

bozhidar09:06:15

There are profiles for each supported Clojure version 1.8-1.10. Generally our support policy is the last 3 versions of Clojure.

bozhidar09:06:39

(which admittedly is kind of random)

dpsutton13:06:10

If anyone wants to pick up the failing tests on CIDER, there seem to be two issues 1) the linter is linting a string of clojure code. Figure out a way to not change this string but inhibit the linter? Alternatively, collapse onto a single line or just accept the weird lint suggestions to fix 2) the tests OOM on emacs-master. I can't run tests locally and now CI successfully can't run them either. No idea why this is happening but there's something there

bozhidar13:06:38

> 1) the linter is linting a string of clojure code. Figure out a way to not change this string but inhibit the linter? Alternatively, collapse onto a single line or just accept the weird lint suggestions to fix

dpsutton13:06:43

ah, it probably thinks its a docstring

diff -u --label /root/project/cider-client.el --label \#\<buffer\ cider-client.el\> /root/project/cider-client.el /tmp/buffer-content-2698iXy
--- /root/project/cider-client.el
+++ #<buffer cider-client.el>
@@ -401,17 +401,17 @@
 
 (defconst cider-info-form "
 (do
-  (require ')
-  (require 'clojure.walk)
+ (require ')
+ (require 'clojure.walk)
 
-  (if-let [var (resolve '%s)]
-    (let [info (meta var)]
-      (-> info
-          (update :ns str)
-          (update :name str)
-          (update :file (comp str ))
-          (assoc :arglists-str (str (:arglists info)))
-          (clojure.walk/stringify-keys)))))
+ (if-let [var (resolve '%s)]
+     (let [info (meta var)]
+       (-> info
+           (update :ns str)
+           (update :name str)
+           (update :file (comp str ))
+           (assoc :arglists-str (str (:arglists info)))
+           (clojure.walk/stringify-keys)))))
 ")

bozhidar13:06:51

Maybe we can load those forms from a dedicated file or suppress this type of warnings. Unfortunately the lint we’re using is pretty basic and customizations there are problematic. I remember it wasn’t respecting .dir-locals.el last time I checked.

bozhidar13:06:09

Ah, yeah - this is fine I guess.

bozhidar13:06:53

Generally I was hoping to find a way to just have all the forms in a Clojure file from which we load them into user (or whatever) and simply refer to their var names in the Elisp code.

bozhidar13:06:10

Never had the time to pursue this idea, though. I think it won’t be hard.

bozhidar13:06:53

> 2) the tests OOM on emacs-master. I can’t run tests locally and now CI successfully can’t run them either. No idea why this is happening but there’s something there

bozhidar13:06:06

No idea. It has been like this for a while. Likely some regression in Emacs 27.

dpsutton13:06:45

I'm busy tonight but i can get back to it on thursday. Really looking forward to green tests across the board 🙂

bozhidar14:06:56

You and me both! 🙂

bozhidar14:06:29

I really appreciate you taking the time to work on this, as I’ve been pretty busy most of May and June and the work on CIDER stagnated a bit.

bozhidar14:06:06

Hopefully things are going to pick up in July and August, as I’m hoping to unveil the next CIDER release at “Heart of Clojure” or “Clojure/south”.

bozhidar14:06:18

(early/late August)

Jag Gunawardana16:06:51

I’m having a few issues with Emacs picking up settings from my .dir-locals.el file, from the emacs docs, I would have thought that this would set the variables globally, but they are only set in a cider repl buffer. Any one seen this before. My .dir-locals.el is:

((nil . ((cider-ns-refresh-after-fn . "dev-extras/resume")
         (cider-ns-refresh-before-fn . "dev-extras/suspend")
         (cider-repl-init-code . ("(dev)"))
         (cider-clojure-cli-global-options . "-A:dev")))

Jag Gunawardana16:06:11

I can get things working be running a set-variable on the variables, but would be nice not to have to do this every time I ran emacs.