Fork me on GitHub
#cider
<
2019-01-07
>
manuel07:01:54

hi everybody. With latest CIDER from MELPA, I am getting this:

ERROR: Unhandled REPL handler exception processing message {:op stacktrace, :pprint-fn cider.nrepl.pprint/pprint, :print-length 50, :print-level 50, :session f6e79029-f84e-4318-b301-f9273a1ba72e, :id 33}
clojure.lang.ArityException: Wrong number of args (1) passed to: cider.nrepl.pprint/pprint

manuel07:01:22

do you want me to file an issue on GitHub?

bozhidar07:01:25

@manuel Seems your cider-nrepl snapshot is outdated.

bozhidar07:01:41

This function takes one or two params.

manuel07:01:09

I see, let me check

manuel08:01:02

I only have this as a dependency in my shadow-cljs.edn: [cider/cider-nrepl "0.19.0"]

manuel08:01:00

CIDER seems to be injecting the latest snapshot on jack-in:

[nREPL] Starting server via /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.5.3"} refactor-nrepl {:mvn/version "2.4.0"} cider/cider-nrepl {:mvn/version "0.20.0-SNAPSHOT"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware"]'...

manuel08:01:56

This from the REPL upon jack-in:

;; Connected to nREPL server - 
;; CIDER 0.20.0snapshot (package: 20190105.1840), nREPL 0.5.3
;; Clojure 1.10.0, Java 1.8.0_191

bozhidar08:01:37

That’s a multi-arity function so if you’re on the current build it should work. You can maybe delete whatever build you have locally in .m2/... to force for it to be fetched again.

bozhidar08:01:08

That’s one of the problems of making changes in snapshots - they are not refetched on each update. Don’t recall what exactly their update mechanism was.

dominicm08:01:39

They're cached daily I believe.

bozhidar08:01:01

Hmm. I certainly changed this a few days ago.

dominicm08:01:03

Lein has a -U option which forces snapshot fetching.

dominicm08:01:05

Which indicates it is a once a day check

manuel08:01:19

Deleted the cider directory from .m2. Now I get this:

Caused by: java.io.FileNotFoundException: Could not locate cider/nrepl/middleware/util/cljs__init.class, cider/nrepl/middleware/util/cljs.clj or cider/nrepl/middleware/util/cljs.cljc on classpath.

manuel08:01:22

on jack-in

manuel08:01:46

And I have:

~/.m2/repository/cider/cider-nrepl/0.19.0
❯ l
.rw-------  197 manuel manuel  7 gen  9:09 _remote.repositories
.rw------- 454k manuel manuel  7 gen  9:09 cider-nrepl-0.19.0.jar
.rw-------   40 manuel manuel  7 gen  9:09 cider-nrepl-0.19.0.jar.sha1
.rw------- 6,6k manuel manuel  7 gen  9:09 cider-nrepl-0.19.0.pom
.rw-------   40 manuel manuel  7 gen  9:09 cider-nrepl-0.19.0.pom.sha1

bozhidar08:01:14

And where’s the snapshot?

manuel08:01:36

you're right, my bad 😄

manuel08:01:46

let me update shadow-cljs.edn to use the latest snapshot

manuel08:01:16

all fixed. Thank you @bozhidar!

manuel13:01:08

I have a CLJ/CLJS project, with shadow-cljs set up as I wrote at the end of this post: https://manuel-uberti.github.io/programming/2018/11/14/deps-shadow-cljs/ Every time I switch from a CLJ buffer to a CLJS buffer (within the same project), I end up with a buffer without its REPL "attached". If I switch to the relevant REPL and then back to the buffer, I get the REPL "attached" and I can C-c C-z to it as usual.

manuel13:01:05

Problem is I have to do it every time. 🙂

manuel13:01:59

FWIW, I switch buffers with C-x b which is bound to ivy-switch-buffer.

manuel13:01:24

And it does not happen if I switch from a CLJ buffer to a CLJ one, or from a CLJS buffer to another CLJS buffer.

Ian Fernandez13:01:17

What's the enviroment varibale for repl output to have line breaks?

dpsutton14:01:40

i'm not sure i'm following what you mean. can you tell me what behavior you are looking to have? output having linebreaks isn't really matching up with anything for me

Ian Fernandez14:01:17

when I get a map return and it's having a reaally long output

Ian Fernandez14:01:05

I want to have line breaks, like:

{:a "12071906913863921875721521"
 :c "idhgsaukgfuksagfsajfgksajfkasjfgaskjfgaskjfgsakjfgsaj"}

Ian Fernandez14:01:28

cider-repl is giving me

bozhidar14:01:31

It’s not an environment variable.

Ian Fernandez14:01:37

{:a "12071906913863921875721521" :c "idhgsaukgfuksagfsajfgksajfkasjfgaskjfgaskjfgsakjfgsaj"}

bozhidar14:01:49

You have to enable cider-repl-use-pretty-print ot whatever it was named.

Ian Fernandez14:01:53

(use-package clojure-mode
  :ensure t
  :config (add-hook 'clojure-mode-hook #'aggressive-indent-mode)
          (add-hook 'clojure-mode-hook #'paredit-mode)
          (add-hook 'clojure-mode-hook (lambda () (parinfer-mode t)))
          (add-hook 'clojurescript-mode-hook #'paredit-mode)                                                                                                                                            
          (add-hook 'clojure-mode-hook (lambda () (rainbow-delimiters t)))
          (add-hook 'cider-repl-mode-hook (lambda () (parinfer-mode t)))
          (add-hook 'cider-repl-mode-hook (lambda () (rainbow-delimiters t))
          (setq cider-repl-pop-to-buffer-on-connect 'display-only)
          (setq cider-repl-use-clojure-font-lock nil)
          (setq cider-repl-use-pretty-printing t)
          (setq cider-repl-wrap-history t)
          (setq cider-repl-result-prefix ";; => "))

Ian Fernandez14:01:10

it's on cider, not in clojure mode?

bozhidar14:01:32

Well, it doesn’t really matter where you set it. Your config seems correct.

bozhidar14:01:16

You also need to adjust *print-right-margin* if you want it to break small data structures. I think by default it’s 70 or something like this.

dpsutton14:01:36

if you have a repl open right now, hit , (comma) in it and select toggle-pretty option in that menu

Ian Fernandez14:01:21

I'm starting a repl here, I'll test this

dpsutton14:01:43

(just to see if pretty printing works at all)

bozhidar14:01:53

Yeah, but it’s not just having pretty print enabled.

Ian Fernandez14:01:57

I don't use spacemacs

bozhidar14:01:15

It’s also the configuration - the right margin forces when something has to be printed on multiple lines.

Ian Fernandez14:01:03

how can I activate the margin on repl?

bozhidar14:01:59

More info about the config.

bozhidar14:01:38

(set! *print-right-margin* some-number)

bozhidar14:01:55

Small number will force almost everything to be printed on multiple lines.

bozhidar14:01:40

Just keep in mind that if you have some print options set in CIDER’s own config they’ll override the REPL dynamic vars.

bozhidar14:01:50

By defaults those are nil, so you should be good.

richiardiandrea16:01:12

Just an heads up, it seems like the signature of the pprint function has changed and fipp does not comply to it, causing a 💥 - haven't investigated more deeply atm

richiardiandrea17:01:45

Lol no, pprint function

bozhidar17:01:01

I’m puzzled. fipp and pprint always had different signatures, at least if called with more than one params.

richiardiandrea17:01:57

Uhm, so then my diagnosis is wrong, getting to the office then I will be able to check. I had to disable fipp yesterday

bozhidar17:01:59

Currently we’re not using any pprint function directly anymore - all of them have wrappers with the same API in cider-nrepl.

richiardiandrea17:01:15

Oh ok maybe that is why

richiardiandrea17:01:42

I had cider-pprint-fn set to 'fipp

bozhidar17:01:58

Yeah, that should work just fine.

bozhidar17:01:16

The value is the same, it just points to a different function.

bozhidar17:01:40

Now a pprint function has to take an object and an optional list of config options to control the pprint.

👍 1
bozhidar17:01:04

Also - for something to be a meaningful pprint function it should return a string, not write to stdout.

j0ni19:01:18

hey @bozhidar is this worthy of a but report:

Debugger entered--Lisp error: (void-variable cider-stacktrace-print-length)
  cider-default-err-op-handler()
  cider-default-err-handler()
  #f(compiled-function () #<bytecode 0x1e87921>)()
  #f(compiled-function (response) #<bytecode 0xf03f55>)((dict "ex" "class clojure.lang.Compiler$CompilerException" "id" "233" "root-ex" "class clojure.lang.Compiler$CompilerException" "session" "a06ca30f-047f-4d0f-8999-e8b8e74e641a" "status" ("eval-error")))
  nrepl--dispatch-response((dict "ex" "class clojure.lang.Compiler$CompilerException" "id" "233" "root-ex" "class clojure.lang.Compiler$CompilerException" "session" "a06ca30f-047f-4d0f-8999-e8b8e74e641a" "status" ("eval-error")))
  nrepl-client-filter(#<process nrepl-connection> "d2:ex45:class clojure.lang.Compiler$CompilerException2:id3:2337:root-ex45:class clojure.lang.Compiler$CompilerException7:session36:a06ca30f-047f-4d0f-8999-e8b8e74e641a6:statusl10:eval-erroree")
or am I missing some config or something?

j0ni19:01:54

hmm, maybe I should delete my .elc files since upgrading cider this morning?

Ian Fernandez20:01:07

i'll try fipp another day

bozhidar21:01:31

@j0ni This was a genuine mistake of mine. I’ve just pushed a fix.

j0ni21:01:55

cool cool 🙂

j0ni21:01:21

haha "genuine mistake" - how many intentional bugs have you written? 😅

bozhidar21:01:58

You’d be surprised. 😉

j0ni21:01:18

lol yeah, iirc in the 80s we called that "job security"