Friday, January 20, 2023

Misbehaving REPL

 

So I'm still studying the REPL and leiningen and Reveal and REBL and trying to get it all to work.

For the longest time, I thought the repl and lein went hand-in-hand. It was just some atomic thing you did to access Clojure. Well, lo & behold, they are actually two different things...

Lein is a tool to manage projects and dependencies and such. There are alternatives like boot and deps (I believe). Meanwhile the REPL can just be started standalone without any need to resort to lein. You can do:

java -jar clojure-1.8.0.jar

which seems like an OG way to do it.

You can also use:

clj
This makes use of the Clojure Command Line tool as can be seen in Eric Normand's guide.

So what I was aiming to do was run lein repl and invoke Reveal. I wanted to do this purely from the command line only without using any profiles.clj file. I spent a LOOOONG time trying out all kinds of commands with various switches. No dice!

Here's just a quick snapshot of things I tried. I used the VSCode Calva to assist with different commands I could use, all to no avail.

lein update-in :dependencies conj '[[vlaaad/reveal \"1.3.276\"]]' -- repl

lein update-in :dependencies conj '[[vlaaad/reveal \"1.3.276\"]]' -- repl // persistent vector cannot be cast to class Named
lein update-in :dependencies conj '[[vlaaad/reveal, \"1.3.276\"]]' -- repl // unsupported character \"1.3.276

lein update-in :dependencies conj '["[vlaaad/reveal, \"1.3.276\"]"]' -- repl // Provided artifact is missing a version

lein update-in :dependencies conj '["[vlaaad/reveal 1.3.276]"]' -- repl
lein update-in :dependencies conj '["[vlaaad/reveal \"1.3.276\"]"]' -- repl
lein update-in :dependencies conj '["vlaaad/reveal \"1.3.276\""]' -- repl

lein update-in :dependencies conj '[[vlaaad/reveal,"1.3.276"], [nrepl, "0.9.0"], [cider/piggieback, "0.5.3"], [cider/cider-nrepl, "0.28.0"]]' -- repl

lein update-in :dependencies conj '[vlaaad/reveal,"1.3.276"]' -- update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/piggieback,"0.5.3"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' --repl

lein update-in :dependencies conj '[vlaaad/reveal,"1.3.276"]' -- repl // opens REPL no complaints BUT require doesn't work as it cannot find source code for reveal


lein update-in :dependencies conj \[nrepl/nrepl \ \"0.9.0 \" \] -- update-in :plugins conj \[cider/cider-nrepl \ \"0.28.1 \" \] -- repl :headless :host localhost  


So I was using all these update-in commands without knowing how they work. I got the gist of what it was doing but I was using them as a magic incantation. Then somehow I stumbled onto lein help update-in; it was in the docs all along, just missed it and I saw this in the help:

$ lein update-in :dependencies conj "[slamhound \"1.1.3\"]" -- repl

So a lot easier than what I was trying to do! So I simply did:

$ lein update-in :dependencies conj "[vlaaad/reveal \"1.3.277\"]" -- repl 

and got the REPL going! Success! but that didn't last long, because when I did:

user=> (require '[vlaaad.reveal :as r])

Syntax error (ClassNotFoundException) compiling at (fipp/ednize.clj:1:1).

java/sql/Timestamp

Drats! However, after even MORE noodling around, looks like the version is causing a problem. I went back to 1.3.265 and loookeee here:



Got it to work! And ~/.lein/profiles.clj was empty.
That latest version of reveal seems to be buggy. I'll drop a note in Clojurians slack to see whatsup.


My next task will be to use profiles.cljs and create a REPL with all the goodies: Reveal, REBL, pprint, nicer stack tracing, etc.

No comments:

Post a Comment

Clojurescript with Reveal & VSCode

So my next foray was into getting Reveal to work with Clojurescript ( specifically Shadow-CLJS)  and VSCode and Leiningen. After a number of...