Fork me on GitHub
#biff
<
2023-06-22
>
Alvydas Vitkauskas19:06:35

I’m quite new to Clojure. Trying Biff. I’m using vim with vim-iced plugin. How can I connect to nREPL started by bb dev from vim?

Alvydas Vitkauskas19:06:05

If I JackIn with :IcedJackIn and try to execute some function (like (seed-channels) from Biff tutorial, I get the following error:

Execution error (IllegalArgumentException) at xtdb.api/eval27282$fn$G (api.clj:351).
No implementation of method: :db of protocol: #'xtdb.api/DBProvider found for class: nil

Jacob O'Bryant22:06:06

Looks like :IcedConnect 7888 is what you want. :IcedJackIn will start its own nrepl server instead of connecting to bb dev's nrepl server. That error message gets thrown because in the :IcedJackIn process, the system hasn't been started, so the :biff.xtdb/node key in the system map is nil, hence ... found for class: nil https://liquidz.github.io/vim-iced/vim-iced.html#%3AIcedConnect

Alvydas Vitkauskas06:06:15

:IcedConnect 7888 was my first try, but it gives me an error:

iced-nrepl is not enabled. Please launch repl with the `iced repl` command.

Alvydas Vitkauskas07:06:24

I also tried :IcedConnectSocketRepl 7888 and it says Connected, but then no evaluation happens when I try something (even (+ 1 2)). I love Clojure, but tooling is difficult for beginners :(

Alvydas Vitkauskas07:06:25

Well, when I do IcedConnect 7888 it gives me a message

iced-nrepl is not enabled. Please launch repl with the `iced repl` command.
but looks like it does conncet to nrepl as I can evaluate expressions. But I cannot get the context with (biff/assoc-db @main/system) - it gives an error
Execution error (IllegalArgumentException) at xtdb.api/eval27282$fn$G (api.clj:351).
No implementation of method: :db of protocol: #'xtdb.api/DBProvider found for class: nil

Alvydas Vitkauskas12:06:28

Got it! I had another clojure repl running in a separate terminal :man-facepalming: and this somehow interfered with nrepl, I suppose. When I stopped it, everything works now! Uh..

Epidiah Ravachol13:06:46

A while back I had a problem getting bb dev and vim-iced to work together and if I remember correctly, the solution was to add iced.nrepl/wrap-iced to the "--middleware" arg in :biff.tasks/clj-args. So it ended up looking a bit like this:

:biff.tasks/clj-args ["-J-XX:-OmitStackTraceInFastThrow"
                               "-J-XX:+CrashOnOutOfMemoryError"
                               "-M" "-m" "com.example"
                               "--port" "7888"
                               "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor,iced.nrepl/wrap-iced]"]

Epidiah Ravachol14:06:47

Oops, should've mentioned this is all in config.edn.

Alvydas Vitkauskas14:06:03

Yes, I found it. And your suggestions look promising indeed. But I get an error when put iced.nrepl/wrap-iced in:

Execution error (FileNotFoundException) at nrepl.cmdline/require-and-resolve (cmdline.clj:220).
Could not locate iced/nrepl__init.class, iced/nrepl.clj or iced/nrepl.cljc on classpath.
Could you suggest what’s wrong? P.S. And yes, I do need to fix it somehow, as I managed to connect to bb dev nrepl once somehow, but it does not work for me again now.

Alvydas Vitkauskas15:06:33

Added com.github.liquidz/iced-nrepl {:mvn/version "1.2.480"} to deps.edn and looks like all works well now again. Thanks @U03RJ0AMUS1!

Epidiah Ravachol15:06:30

Ah yes! I forgot that part, too! I'm very happy it's working now!

Jacob O'Bryant17:06:55

ah glad it's all working! might not hurt to put some of that info in a gist and link to it from the docs...

Alvydas Vitkauskas21:06:30

@U7YNGKDHA, I created a gist. You can copy it to your own gists if you want. @U03RJ0AMUS1, all the credits should be yours, how should I refer you on github? https://gist.github.com/avitkauskas/88ddc3c9b297f431143e22f36a224459

Alvydas Vitkauskas12:06:28

BTW, @U7YNGKDHA would you consider adding dependency of iced-repl and its middleware wrapper into your example application template (perhaps commented out or something, with the remark for vim-iced users to uncomment it)? On the other side, I do not need cider.nrepl/cider-middleware and refactor-nrepl.middleware/wrap-refactor wrappers as I do not use Emacs. I could make a PR if you wish.

Jacob O'Bryant18:06:51

Thanks--just added a link to the gist in the https://biffweb.com/docs/get-started/new-project/ and in the https://biffweb.com/docs/library/. As for including it in deps.edn, I think better to just leave it as separate documentation. The cider middleware I think makes sense to include because it's used by https://github.com/clojure-emacs/cider-nrepl#cider-nrepl, not just emacs: > cider-nrepl is also used by vim-fireplace, iced-vim, Calva and other Clojure development tools based on nREPL. (Apparently iced-vim uses it too 🤷 )

👍 2
Epidiah Ravachol13:06:56

Hey, thanks @U05E4BRHBCG! I'm Epidiah just about everywhere, including github: https://github.com/Epidiah But I'm pretty sure I was just relaying some info given to me when I asked a similar question in this channel a few months ago. So I can't really take the credit.

👍 2