Fork me on GitHub
#cider
<
2019-05-07
>
pataprogramming13:05:38

In the process of trying to get a weirdly configured old project updated and running, I've managed to bork CIDER completely, and am no longer able to either cider-jack-in or cider-connect. - Emacs 26.2 - Getting the problem for both lein and boot projects - Nothing CIDER or nrepl-refactor related in lein profile.clj - cider 20190419.1025 - clj-refactor 20190425.1002 - clojure-mode 20190413.909 - But am getting the problem both with CIDER 0.21.0 and CIDER 0.22.0-SNAPSHOT

pataprogramming13:05:59

[nREPL] Starting server via /home/pls/bin/lein update-in :dependencies conj \[nrepl\ \"0.6.0\"\] -- update-in :plugins conj \[refactor-nrepl\ \"2.4.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.22.0-SNAPSHOT\"\] -- repl :headless :host localhost...
[nREPL] server started on 42613
[nREPL] Establishing direct connection to localhost:42613 ...
[nREPL] Direct connection to localhost:42613 established
map-apply: Wrong type argument: sequencep, #s(hash-table size 2 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("right-margin" 70 "length" 50))

pataprogramming13:05:07

Here's a backtrace with .lein/profiles.clj disabled on a fresh lein project:

pataprogramming13:05:40

Any assistance would be appreciated, as I've got a interactive presentation later today.

pataprogramming13:05:15

I spent a couple of hours last night slogging through the elisp trying to figure out what's going on...`map-pairs` definitely doesn't like hash table. I tried turning it into a list with a manually written function, but that just pushed the problems further down the line.

pataprogramming15:05:43

Basically, what I tried was replacing map-pairs with

(defun hash-to-list (hash)
  (let (result)
    (maphash
     (lambda (k v)
       (push (list k v) result))
     hash)
    result))
This gives what looks like a sane output to cider--repl-request-map, but resulted in another failure in the function calling it.

pataprogramming15:05:54

Since this problem doesn't seem to have been reported at the issue, and it might be peculiar to my emacs config, I was hoping somebody here might have some guesses.

bozhidar15:05:07

Is your cider-print-options set to nil?

bozhidar15:05:54

I assume it’s not and that the options there are not in the expected format.

pataprogramming15:05:53

Hide cider-print-options: nil
    State : STANDARD. (mismatch)

pataprogramming15:05:03

That mismatch is weird.

pataprogramming16:05:35

cider-print-options is a variable defined in ‘cider-client.el’.
Its value is nil

Documentation:
A map of options that will be passed to ‘cider-print-fn’.
Here’s an example for ‘pprint’:

  ’(("length" 50) ("right-margin" 70))

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 0.21.0 of the cider package.

pataprogramming16:05:38

And jumping to the definition confirms it should be a list. So why would customize report a mismatch?

pataprogramming16:05:46

Looking at the definition of cider--nrepl-print-request-map, there's this bit:

(let* ((width-option (cider--print-option "right-margin" cider-print-fn))
         (print-options (thread-last
                            (map-merge 'hash-table
                                       `((,width-option ,right-margin))
                                       cider-print-options)
                          (map-pairs)
                          (seq-mapcat #'identity)
                          (apply #'nrepl-dict))))
 [...]

pataprogramming16:05:33

Cutting it down to

(thread-last
    (map-merge 'hash-table
               `(("width" 50) ("right-margin" 70))
               nil)
  (map-pairs)
  (seq-mapcat #'identity)
  (apply #'nrepl-dict))
the wrong-type-argument error pops up

pataprogramming16:05:58

It's like the right definition isn't available for map-pairs on the hash table, and I'm not certain how this could work at all, since I'm guessing cons doesn't work on hash tables?

(cl-defgeneric map-pairs (map)
  "Return the elements of MAP as key/value association lists.
The default implementation delegates to `map-apply'."
  (map-apply #'cons map))

pataprogramming16:05:14

Debugger entered--Lisp error: (wrong-type-argument sequencep #<hash-table equal 0/1 0x2b8fbf5>)
  mapcar((lambda (l) (apply func l)) #<hash-table equal 0/1 0x2b8fbf5>)
  map-apply(cons #<hash-table equal 0/1 0x2b8fbf5>)
  map-pairs(#<hash-table equal 0/1 0x2b8fbf5>)
  (seq-mapcat (function identity) (map-pairs (map-merge (quote hash-table) cider-print-options)))

pataprogramming17:05:55

So it apparently delegates to map-apply in map.el, which should theoretically be able to figure out that a hash table is being passed in.

pataprogramming17:05:14

I'm kind of stumped as to why and how this went awry.

pataprogramming17:05:42

packages cl-lib 1.0, map 2.0, seq 2.20 are installed

fedreg16:05:21

Hi all, I updated to latest cider and looks like C-c C-p now prints only stdout stuff to the new *cider-result* buffer, whereas it used to print everything... Before I make my own hack, is anyone aware of any other cider func which prints everything to *cider-result*? didn't see one. Thx!

bozhidar20:05:13

Define everything. 🙂