Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: working with lein #49

Closed
thecontinium opened this issue Jul 14, 2019 · 9 comments

Comments

@thecontinium
Copy link

commented Jul 14, 2019

Hi

How can I setup conjure so that it will connect to an open lein repl

cheers

@Olical

This comment has been minimized.

Copy link
Owner

commented Jul 14, 2019

Yep, the tool you use to start your program doesn't matter, prepl support is tied to Clojure, not the CLI.

You'll just have to start the prepl from your code like I show in my prepl cookbook post: https://oli.me.uk/2019-03-22-clojure-socket-prepl-cookbook/#from_your_code

If you know how to set JVM args with leiningen, then you will be able to start a prepl by defining the following flag.

-Dclojure.server.myprepl="{:port 5555 :accept clojure.core.server/io-prepl}"

There's not much to it 😄 I hope this helps!

@Olical

This comment has been minimized.

Copy link
Owner

commented Jul 15, 2019

I didn't really read the issue properly, I was a little distracted. My comment is still valid, but to elaborate on that: You can't connect to a lein repl because that's an nREPL server, not a socket prepl. The post I linked will show you how to start a socket prepl.

@thecontinium

This comment has been minimized.

Copy link
Author

commented Jul 15, 2019

Thanks for the additional information.

When I add:

{repl: {:jvm-opts ["-Dclojure.server.myprepl=\"{:port 55555 :accept clojure.core.server/io-prepl}\""] }}

to profiles.clj

I get:

lein repl
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.main.(main.java:20)
Caused by: java.lang.ClassCastException: class java.lang.Character cannot be cast to class java.util.Map$Entry (java.lang.Character and java.util.Map$Entry are in module java.base of loader 'bootstrap')
at clojure.lang.APersistentMap.cons(APersistentMap.java:42)
at clojure.lang.RT.conj(RT.java:673)
at clojure.core$conj__5375.invokeStatic(core.clj:85)
at clojure.core$merge$fn__5943.invoke(core.clj:3049)
at clojure.core$reduce1.invokeStatic(core.clj:944)
at clojure.core$reduce1.invokeStatic(core.clj:934)
at clojure.core$merge.invokeStatic(core.clj:3048)
at clojure.core.server$parse_props$fn__8892.invoke(server.clj:152)
at clojure.core.protocols$naive_seq_reduce.invokeStatic(protocols.clj:62)
at clojure.core.protocols$interface_or_naive_reduce.invokeStatic(protocols.clj:72)
at clojure.core.protocols$fn__8144.invokeStatic(protocols.clj:169)
at clojure.core.protocols$fn__8144.invoke(protocols.clj:124)
at clojure.core.protocols$fn__8099$G__8094__8108.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
at clojure.core.protocols$fn__8121.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8121.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8073$G__8068__8086.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core.server$parse_props.invokeStatic(server.clj:146)
at clojure.core.server$start_servers.invokeStatic(server.clj:157)
at clojure.core.server$start_servers.invoke(server.clj:157)
at clojure.lang.Var.invoke(Var.java:384)
at clojure.lang.RT.doInit(RT.java:492)
at clojure.lang.RT.(RT.java:338)
... 1 more
Subprocess failed

Ant ideas ?

@Olical

This comment has been minimized.

Copy link
Owner

commented Jul 15, 2019

Hmm, not sure right now but that repl: doesn't look quite right to me. Maybe :repl?

@thecontinium

This comment has been minimized.

Copy link
Author

commented Jul 16, 2019

FYI this works ( you might want to add to the readme at some point )

With a ~/.lein/profiles.clj of :

{:repl { :repl-options { :init (clojure.core.server/start-server {:accept 'clojure.core.server/io-prepl :address "localhost" :port 55555 :name "lein"})} } }

and conjure.edn of
{:conns { :lein {:port 55555 }}}

makes conjure evals ( connected to 55555 in this case) to be available in the lein nrepl.

@Olical

This comment has been minimized.

Copy link
Owner

commented Jul 16, 2019

Glad you got it working! I'll bear this in mind, could add it to my socket prepl cookbook post too.

@thecontinium

This comment has been minimized.

Copy link
Author

commented Jul 16, 2019

@mn-dimension

This comment has been minimized.

Copy link

commented Jul 21, 2019

would be good if there was a way of getting the port number from profiles.clj in conjure.edn like you can for a single port value in a file.

@Olical

This comment has been minimized.

Copy link
Owner

commented Jul 21, 2019

Hmm, if it's in the profiles.clj file it's a known value though, it's static. So you can just set that in your .conjure.edn anyway, the slurping only really exists for random ports that are spat out into a file by convention.

I'd rather not introduce any more mechanisms if I can help it, static files where you can read more EDN should be enough for almost every case. I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.