reveal

Docs: https://vlaaad.github.io/reveal/ Source: https://github.com/vlaaad/reveal
Célio 2020-10-22T18:53:02.125800Z

Hi, is anyone able to use Reveal with Calva? I was able to fire up an nrepl session with:

clj -A:reveal -m nrepl.cmdline --middleware '[vlaaad.reveal.nrepl/middleware]'
The Reveal shows up, then I’m able to connect to the nrepl session from Calva, but once I start evaluating code from Calva, I don’t see any output in the Reveal window except this:
*ns*
=> user

vlaaad 2020-10-22T19:10:49.125900Z

Hmm, I just tried using Reveal with Calva today

vlaaad 2020-10-22T19:11:30.126Z

Worked fine, I did what you did: started nrepl in terminal and connected to it with Calva

vlaaad 2020-10-22T19:11:41.126100Z

Any exceptions somewhere?

Célio 2020-10-22T19:20:57.127100Z

I just checked Calva’s logs but don’t see any exceptions.

Célio 2020-10-22T19:22:03.128300Z

I’m probably doing something wrong. When I eval e.g.: {:a 1} I can see the eval output coming out in the Calva repl output, but nothing comes out in the Reveal window.

Célio 2020-10-22T19:22:54.128700Z

Btw, no exceptions in the nrepl session output either.

Célio 2020-10-22T19:29:16.131900Z

Quick summary of the steps I took: 1. run clj -A:reveal -m nrepl.cmdline --middleware '[vlaaad.reveal.nrepl/middleware]' in the terminal 2. Check out the reveal window, it’s empty 3. Go to Calva and type ctrl+c ctrl+c 4. Select Clojure CLI as project type 5. Select the nrepl port 6. As soon as Calva connects, I see => user namespace appear in the output 7. Place the cursor on some form and type ctrl+enter 8. The eval result appears in Calva’s repl output, but nothing appears in the reveal window.

vlaaad 2020-10-22T19:47:53.132300Z

what's your reveal alias?

vlaaad 2020-10-22T19:51:12.132900Z

I started with this:

$ clj -Sdeps "{:deps {nrepl/nrepl {:mvn/version """"0.6.0""""} vlaaad/reveal {:mvn/version """"1.0.130""""}}}" -M -m nrepl.cmdline --middleware "[vlaaad.reveal.nrepl/middleware]"
(multiple quotes because it's powershell)

Célio 2020-10-22T19:52:06.133300Z

This is my reveal alias:

{:reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.0.130"}
                                 nrepl/nrepl {:mvn/version "0.8.2"}}}}

Célio 2020-10-22T19:53:02.133700Z

let me try with nrepl 0.6.0

vlaaad 2020-10-22T19:53:15.133900Z

0.8.2 also works for me

vlaaad 2020-10-22T19:54:00.134600Z

I don't know about shortcuts, but I used "calva: connect..." action where I needed to specify the port

vlaaad 2020-10-22T19:54:35.135Z

and then "calva: evaluate current form"

Célio 2020-10-22T19:55:52.135500Z

yeah the shortcuts I used match the commands you used

Célio 2020-10-22T19:56:42.136100Z

ok I see something different in the reveal window:

(try
  (clojure.lang.Compiler/load 
   (java.io.StringReader. 
    ((clojure.core/deref 
      (clojure.core/deref 
       (var nrepl.middleware.load-file/file-contents))) 
     (quote 
      ["/Users/ccidral/lusa/tools/api-script/src/api_script/core.clj" G__7056]))) 
   "/Users/ccidral/lusa/tools/api-script/src/api_script/core.clj" "core.clj") 
  (finally 
    (clojure.core/swap! 
     (clojure.core/deref (var nrepl.middleware.load-file/file-contents)) 
     clojure.core/dissoc 
     (quote ["/Users/ccidral/lusa/tools/api-script/src/api_script/core.clj" G__7056]))))
=> nil

Célio 2020-10-22T19:57:56.137400Z

I remember seeing this before, the first time I ran reveal with nrepl 0.8.2, and then I didn’t see it anymore. Now that I changed nrepl version to 0.6.0 this output appeared again.

Célio 2020-10-22T19:59:22.138Z

It printed out this output when I evaluated my the whole core.clj file.

Célio 2020-10-22T20:02:13.140Z

I right-clicked on that output and selected view:value. It shows a huge map, looks like some nrepl internal state. There’s an error in there:

"Could not locate clj_kondo/core__init.class, clj_kondo/core.clj or clj_kondo/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name."

vlaaad 2020-10-22T20:02:22.140200Z

this kind of stuff is unavoidable with nrepl because there is no good way to tell in the nrepl if sent command is user-triggered evaluation or some tool is doing that

Célio 2020-10-22T20:03:06.140800Z

some more context:

#'clojure.core/*e #reveal/error{:via [{
    :type java.io.FileNotFoundException
    :message "Could not locate clj_kondo/core__init.class, clj_kondo/core.clj or clj_kondo/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name."
    :at [clojure.lang.RT load "RT.java" 462]}]

vlaaad 2020-10-22T20:03:09.140900Z

(I'm talking about these kinds of forms that appear from time to time)

vlaaad 2020-10-22T20:03:35.141300Z

I guess calva tries to require clj-kondo for some reason

vlaaad 2020-10-22T20:05:32.142Z

can you try in empty project?

Célio 2020-10-22T20:05:41.142400Z

sure

Célio 2020-10-22T20:09:39.143500Z

Same behavior. It prints that (try (clojure.lang.Compiler/load … output.

Célio 2020-10-22T20:09:53.143900Z

Let me see what happens if I add clj-kondo to the deps

Célio 2020-10-22T20:13:16.144700Z

Added clj-kondo dep, I don’t see that output anymore, but I’m getting the same behavior as before.

Célio 2020-10-22T20:14:06.145300Z

This is my deps.edn file:

{:aliases {:reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.0.130"}
                                 nrepl/nrepl {:mvn/version "0.8.2"}
                                 clj-kondo/clj-kondo {:mvn/version "2020.10.10"}}}}}
And this is my src/empty_proj/core.clj file:
(ns empty-proj.core)

{:a 1}

Célio 2020-10-22T20:15:30.146100Z

I’ll keep digging tomorrow and keep you posted.

Célio 2020-10-22T20:15:47.146400Z

Thanks for the help!