babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2020-10-23T14:50:57.078400Z

A new CLI: https://github.com/borkdude/puget-cli Can be used to colorize / pprint EDN.

⭐ 1
😎 8
solf 2020-10-23T21:45:35.081400Z

I'm having issues showing the documentation of a variable using CIDER (with C-c C-d C-d or cider-doc). It doesn't use the symbol at point, and even if I type it, it returns an error. Example trace with map:

Debugger entered--Lisp error: (wrong-type-argument stringp ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]))
  string-match("\n" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]) 0)
  split-string(([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]) "\n")
  cider-docview-render-info(#<buffer *cider-doc*> (dict "ns" "clojure.core" "name" "map" "built-in" t "arglists" "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &..." "doc" "Returns a lazy sequence consisting of the result o..." "file" "" "arglists-str" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
  cider-docview-render(#<buffer *cider-doc*> "map" (dict "ns" "clojure.core" "name" "map" "built-in" t "arglists" "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &..." "doc" "Returns a lazy sequence consisting of the result o..." "file" "" "arglists-str" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
  cider-create-doc-buffer("map")
  cider-doc-lookup("map")
  cider-try-symbol-at-point("Doc for" cider-doc-lookup)
  cider-doc(nil)
  funcall-interactively(cider-doc nil)
  call-interactively(cider-doc nil nil)
  command-execute(cider-doc)

borkdude 2020-10-23T21:47:22.082Z

Does cider-doc require some non-standard nREPL middleware?

borkdude 2020-10-23T21:47:49.082200Z

it would be helpful if you could post the output from the nrepl messages buffer

solf 2020-10-23T21:48:10.082400Z

No idea. I'm almost positive cider-doc worked before. I'll check the result from the nrepl buffer

borkdude 2020-10-23T21:48:42.082600Z

You could try using an older release to double check if it worked before.

solf 2020-10-23T21:49:16.083Z

I'll try that, at the moment using:

`--> bb --version
babashka v0.2.3
CIDER 1.0.0snapshot (package: 20201020.1058)

solf 2020-10-23T21:49:44.083200Z

(I just updated CIDER to see if it fixed the error, don't remember how old was my previous version)

solf 2020-10-23T21:53:06.083400Z

I haven't checked older versions on the nrepl buffer yet, but looking at the error stacktrace I can see that the result from nrepl contains both an arglists and an arglists-str

solf 2020-10-23T21:53:23.083600Z

however neither is a string

solf 2020-10-23T21:53:41.083800Z

And then CIDER is splitting arglists-str thinking it's a string, which throws the error

solf 2020-10-23T21:56:51.084Z

No there's no specific nrepl op for doc

solf 2020-10-23T21:57:10.084200Z

instead eval is used:

(-->
  id         "22"
  op         "eval"
  session    "31de0313-76e6-4bf8-89bf-22e284741af8"
  time-stamp "2020-10-23 23:55:22.795699101"
  code       "
(do
  (require '<http://clojure.java.io|clojure.java.io>)
  (require 'clojure.walk)

  (if-let [var (resolve 'map)]
    (let [info (meta var)]
      (-&gt; info
          (update :ns str)
          (update :name str)
          (update :file (comp str <http://clojure.java.io/resource|clojure.java.io/resource>))
          (cond-&gt; (:macro info) (update :macro str))
          (cond-&gt; (:special-form info) (update :special-form str))
          (cond-&gt; (:protocol info) (update :protocol str))
          (cond-&gt; (:arglists info) (update :arglists str))
          (assoc :arglists-str (:arglists info))
          (clojure.walk/stringify-keys)))))
"
)
(&lt;--
  id         "22"
  session    "31de0313-76e6-4bf8-89bf-22e284741af8"
  time-stamp "2020-10-23 23:55:22.805649515"
  ns         "hello"
  value      "{\"ns\" \"clojure.core\", \"name\" \"map\", \"built-in\" true, \"arglists\" \"([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &amp; colls])\", \"doc\" \"Returns a lazy sequence consisting of the result of applying f to\\n  the set of first items of each coll, followed by applying f to the\\n  set of second items in each coll, until any one of the colls is\\n  exhausted.  Any remaining items in other colls are ignored. Function\\n  f should accept number-of-colls arguments. Returns a transducer when\\n  no collection is provided.\", \"file\" \"\", \"arglists-str\" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &amp; colls])}"
)

solf 2020-10-23T21:59:15.084400Z

.... sorry, this is my bad, it comes from my config customization

borkdude 2020-10-23T21:59:25.084600Z

ok

solf 2020-10-23T21:59:48.084800Z

I completely forgot, but I added support for cider-doc myself a few months ago, I guess the code is out of date now

solf 2020-10-23T21:59:59.085Z

the clj function in the nrepl eval comes from my config

solf 2020-10-23T22:01:57.085300Z

Hey no, it doesn't! https://github.com/clojure-emacs/cider/blob/1be3b89c00d9fe6d2b69e5b719d168e22d333a25/cider-client.el#L422 This is late for me, so I'll continue to investigate this tomorrow and will create an issue in babashka/nrepl then

solf 2020-10-23T22:04:22.085700Z

Nevermind, found it, and it's a bug in cider, I'll file a report there. The eval code is a fallback when there's no nrepl support for the op info, which is why it happens on babashka. Commit in question: https://github.com/clojure-emacs/cider/commit/1be3b89c00d9fe6d2b69e5b719d168e22d333a25

borkdude 2020-10-23T22:04:57.085900Z

That expression does seem to work when evaluated as a normal bb script

borkdude 2020-10-23T22:05:16.086200Z

E.g. for map I get:

{"ns" "clojure.core", "name" "map", "built-in" true, "arglists" "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &amp; colls])", "doc" "Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided.", "file" "", "arglists-str" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &amp; colls])}
`

solf 2020-10-23T22:05:37.086400Z

the eval works, but the commit introduced a bug: arglists-str is not a string anymore

solf 2020-10-23T22:05:52.086600Z

so emacs throws when trying to split it by \n

borkdude 2020-10-23T22:06:07.086800Z

ah ok

borkdude 2020-10-23T22:06:35.087Z

Getting late here too, I think we're in the same timezone

solf 2020-10-23T22:06:57.087200Z

now yes! I did a tad of work on babashka/nrepl when I was in Singapore, but now I'm in france to visit my family

borkdude 2020-10-23T22:07:17.087400Z

ah nice.

solf 2020-10-23T22:07:40.087600Z

I care about having babashka work well with cider ahah

solf 2020-10-23T22:07:43.087800Z

good night then

borkdude 2020-10-23T22:08:08.088Z

same to you :)