nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2018-12-04T08:00:49.005500Z

This approach to handle large result chunks seems pretty neat: https://youtu.be/c52QhiXsmyI

Jakub Holý 2018-12-04T10:34:30.007400Z

Hi! I want to show a greeting message to the client when connected to my nrepl server but can't figure out how to use :greeting-fn for that. The transport/tty-greeting is quite simple but does not work with a non-tty transports it seems (my client reports the conn was reset when I try to use it). Any tips? 🙏

bozhidar 2018-12-04T10:55:45.008400Z

@holyjak Generally the clients are supposed to provide the greeting message. TTY is an exception as there if you don’t send something server-side you won’t even realize you’ve connected.

bozhidar 2018-12-04T10:56:56.009Z

If you elaborate on what you’re trying to achieve I might be able to give you some alternative idea.

bozhidar 2018-12-04T11:02:22.010100Z

Btw, I’m puzzled that the greeting fn approach didn’t work for you - it’s a very generic way of sending some message(s) on connect. This should be just fine regardless of your transport.

Jakub Holý 2018-12-04T12:03:45.010300Z

Thanks @bozhidar! I have a legacy java/groovy app and want to start a nrepl server within the app so that I could explore it while it is running. I also want to provide convenience vars, fns to interact with it, namely its Spring App.Context. I want to print a message when I connect from a nrepl client to show what vars / fns there are. As you can see, I have currently #_-commented it out.

bozhidar 2018-12-04T12:06:43.010900Z

What’s the client you’re using? And what is the exact error you’re getting?

Jakub Holý 2018-12-04T12:07:06.011Z

If I start the server like this, from a clj repl: (require '[nrepl.server :as n]) (n/start-server :port 55555 :greeting-fn (fn [t] (send t {:out "Welcome!"}))) and connect to it from Cursive, I get at once in the client: > Connecting to remote nREPL server... > Exception starting REPL: java.net.SocketException: Connection reset

Jakub Holý 2018-12-04T12:11:20.011500Z

Similarly from the command line:

$ clj -R:nrepl -m nrepl.cmdline --connect --host 127.0.0.1 --port 55555
Exception in thread "main" java.net.SocketException: The transport's socket appears to have lost its connection to the nREPL server
	at nrepl.transport$bencode$fn__691$fn__692.invoke(transport.clj:92)
	at nrepl.transport$bencode$fn__691.invoke(transport.clj:92)
	at nrepl.transport$fn_transport$fn__647.invoke(transport.clj:39)
(The :nrepl alias = {:extra-deps {nrepl/nrepl {:mvn/version "0.4.5"}}}) (Same with nrepl 0.5.0)

bozhidar 2018-12-04T14:54:43.012800Z

Please, meet our newest maintainer of nREPL - the one and only @cgrand! :man-bowing: Time to make nREPL as awesome as unREPL. 😉

🎉 4
cgrand 2018-12-04T14:55:49.013200Z

Let’s make nrepl great again (oh this joke is getting old)

Jakub Holý 2018-12-04T15:13:19.013400Z

could it be a bug?

pez 2018-12-04T15:24:16.014100Z

MNGA! I like it.

2018-12-04T19:55:25.015700Z

Hi! I've got

{:repl {:dependencies [[nrepl/nrepl "0.5.1"]]
        :plugins      [[cider/cider-nrepl "0.18.0"]]}}
in ~/.lein/profiles.clj, but when I cider-jack-in I'm still getting nREPL 0.2.12. What might I be missing?

dominicm 2018-12-04T20:02:35.016800Z

@dchelimsky I don't know that cider attempts to use nrepl/nrepl with leiningen, it defers to leiningen. I'm not sure if lein-nrepl (https://github.com/nrepl/lein-nrepl) can be configured to work.

dominicm 2018-12-04T20:03:09.017300Z

https://github.com/nrepl/lein-nrepl#using-with-cider

(setq cider-inject-dependencies-at-jack-in nil)
(setq lein-parameters "nrepl")
Apparently 🙂

2018-12-04T20:09:17.018400Z

Thanks for the help @dominicm. Unfortunately, I now have

:repl {:dependencies [[nrepl/nrepl "0.5.1"]]
        :plugins      [[cider/cider-nrepl "0.18.0"]
                       [nrepl/lein-nrepl "0.3.1"
                        :exclusions [org.clojure/clojure
                                     nrepl
                                     commons-io
                                     commons-codec]]]}
in profiles.clj and
(setq cider-inject-dependencies-at-jack-in nil)
(setq lein-parameters "nrepl")
in init.el and I still get nREPL 0.2.12

dominicm 2018-12-04T20:14:27.018900Z

@dchelimsky When jack-in runs, can you see whether it runs lein repl or lein nrepl?

2018-12-04T20:15:25.019200Z

repl

2018-12-04T20:15:40.019700Z

Which suggests that (setq lein-parameters "nrepl") isn't being read

dominicm 2018-12-04T20:16:48.020400Z

I'm not an emacs/cider user, so I'm not much help here I'm afraid. M-x customize-var might be able to tell you the proper variable name though.

2018-12-04T20:17:01.020700Z

Just trying that

2018-12-04T20:17:42.021300Z

Oh, weird. Now I get "'nrepl' is not a task". Progress!

dominicm 2018-12-04T20:20:54.022100Z

@dchelimsky I think your problem is that you've put the lein-nrepl plugin inside of the :repl profile. Maybe it should be the :user profile? I guess :repl is only loaded for lein repl?

2018-12-04T20:28:48.023400Z

Yes, that makes sense. Now, of course, I'm getting dependency conflicts that are apparently not-resolvable. :pedantic? :abort is telling me to exclude something but when I exclude it I still get the same message.

dominicm 2018-12-04T20:30:10.024500Z

@dchelimsky Exclusions added to plugins are ignored. It's an counter-intuitive quirk of leiningen. The trick is to add a dependency on lein-nrepl with the exclusions, as well as having the :plugins for it.

2018-12-04T20:32:03.025Z

"as well as having the :plugins for it." meaning also include lein-nrepl in plugins, but without the exclusions?

dominicm 2018-12-04T20:33:48.025300Z

@dchelimsky correct 🙂

2018-12-04T20:42:02.028200Z

I still get the messages if I leave out the exclusions from :plugins

dominicm 2018-12-04T20:42:32.028800Z

@dchelimsky did you move them to :dependencies?

2018-12-04T20:43:14.029100Z

:user {:dependencies [[nrepl/nrepl "0.5.1"]
                       [nrepl/lein-nrepl "0.3.1"
                        :exclusions [org.clojure/clojure
                                     nrepl
                                     commons-io
                                     commons-codec]]]
        :plugins      [[cider/cider-nrepl "0.18.0"]
                       [nrepl/lein-nrepl "0.3.1"
                        :exclusions [org.clojure/clojure
                                     nrepl
                                     commons-io
                                     commons-codec]]]

2018-12-04T20:43:31.029800Z

without the exclusions in :plugins I get all the warning messages

dominicm 2018-12-04T20:43:46.030100Z

oh, I'd thought that would work 😞 I'm not sure then, sorry. I know this is a weird thing that happens with plugins because of the trampoline system.

2018-12-04T20:44:43.031200Z

It gets even weirder, because now I also need to exclude clojure-complete, but I'm not requiring that anywhere and it's showing up at the top of lein deps :tree, meaning something, somewhere is injecting it 😕

2018-12-04T20:45:06.031700Z

And if I exclude it, I get compilation errors! Yay!

2018-12-04T20:45:37.032400Z

Thanks for trying to help @dominicm. I appreciate it.

dominicm 2018-12-04T20:47:25.033100Z

Thank you for your talk on AWS 🙂 I'm excited to see what I can do with the aws libs! (although true input streams will be very useful for me!)

2018-12-04T20:50:32.033800Z

@dominicm feel free to comment on https://github.com/cognitect-labs/aws-api/issues/14

dominicm 2018-12-04T20:51:04.034500Z

You're already ahead of me then! 😄 I will add my 👍 (assuming this is the equivalent of a JIRA vote)

2018-12-04T20:52:15.035300Z

Not equivalent of a JIRA vote, but it makes me feel good 🙂

2018-12-04T20:52:46.035900Z

Might end up being equivalent. We just haven't discussed it internally.