Fork me on GitHub
#nrepl
<
2018-12-04
>
pez08:12:49

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

Jakub Holý (HolyJak)10:12:30

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? 🙏

bozhidar10:12:45

@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.

bozhidar10:12:56

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

bozhidar11:12:22

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ý (HolyJak)12:12:45

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.

Jakub Holý (HolyJak)12:12:06

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ý (HolyJak)12:12:20

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)

Jakub Holý (HolyJak)07:12:32

Sorry to bother @bozhidar, have you found out something? Thank you!!!

bozhidar12:12:43

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

bozhidar14:12:43

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

🎉 16
cgrand14:12:49

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

pez15:12:16

MNGA! I like it.

dchelimsky19:12:25

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?

dominicm20:12:35

@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.

dominicm20:12:09

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

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

dchelimsky20:12:17

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

dominicm20:12:27

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

dchelimsky20:12:40

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

dominicm20:12:48

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.

dchelimsky20:12:01

Just trying that

dchelimsky20:12:42

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

dominicm20:12:54

@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?

dchelimsky20:12:48

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.

dominicm20:12:10

@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.

dchelimsky20:12:03

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

dchelimsky20:12:02

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

dominicm20:12:32

@dchelimsky did you move them to :dependencies?

dchelimsky20:12:14

: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]]]

dchelimsky20:12:31

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

dominicm20:12:46

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.

dchelimsky20:12:43

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 😕

dchelimsky20:12:06

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

dchelimsky20:12:37

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

dominicm20:12:25

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!)

dominicm20:12:04

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

dchelimsky20:12:15

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

dchelimsky20:12:46

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