cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
chadharrington 2021-06-30T02:08:53.211100Z

I am working on a project which has both a Clojure client and a Clojure server. I want to run two REPLs, one for the server and one for the client. I can start and connect to the two REPLs just fine. When I evaluate code in the server.clj buffer, I want it to go to the server REPL. When I evaluate code in the client.clj buffer, I want it to go to the client REPL. Unfortunately, this seems to be hit and miss. The "Manging Connections" docs (https://docs.cider.mx/cider/usage/managing_connections.html) talk about sessions and various commands, but don't understand how to associate a specific REPL with a specific code buffer. I have tried to use the "recency" concept discussed in the docs, by switching to the appropriate REPL and evaluating a trivial expression. I assume this means that REPL is now the most recent REPL. Then I switch to the appropriate code buffer and hit C-c M-z. Sometimes, the code is evaluated in the "recent" REPL and sometimes it's evaluated in the other REPL. This is very frustrating to me. It seems like there should be a simple command to define the desired association; I am probably just not understanding how this is supposed to work. Has anyone done this? Any examples?

dpsutton 2021-06-30T02:39:48.213300Z

I'm not familiar with two repls of the same type. The recency thing is usually for when the repls are clj and cljs, and CIDER gets confused. I'm not familiar with what happens when there are two repls of the same type. If you could file an issue ideally with a repro it would be helpful. I think bozhidar has mentioned he's not a fan of the session management code in CIDER at the moment (lovingly called sesman). I suspect that that will be gutted sooner or later

bozhidar 2021-06-30T07:09:35.215700Z

With two REPLs of the same type, the most recently used will be preferred.

bozhidar 2021-06-30T07:09:44.215900Z

(or at least it should be)

bozhidar 2021-06-30T07:10:58.216100Z

There's currently no way to map a buffer a REPL like it was possible to do in the past - buffers are mapped to sessions and within the sessions source buffers are mapped to connections (REPLs) using sesman's logic (most relevant type, then most recent).

bozhidar 2021-06-30T07:13:24.216300Z

As for the future of sesman - that mostly depends on whether I'll find the time and the desire to tackle bigger changes. I don't think that the idea of sessions is fundamentally bad (especially if you have both types of connections for some project), I mostly want to remove the complex session mapping that sesman does with something more straightforward (or at the very least restore static session mapping as an option).

chadharrington 2021-06-30T16:00:24.216800Z

Thanks for the replies. Unfortunately, as mentioned, the recency concept is unreliable with two clj repls. I am in the middle of a big project w/ a deadline, so I can't spend more time on this right now. I will try to log an issue with a reproduction in the future.

chadharrington 2021-06-30T16:00:38.217Z

Static session mapping would be great. Simpler is better, right?

dpsutton 2021-06-30T16:02:17.217300Z

i think so. inf-clojure has this notion and it is quite nice. In some places it might be less convenient but having the ultimate predictability has its benefits

2021-07-03T19:00:04.249700Z

FWIW i just found this thread looking for this same functionality -- two sibling CLJ REPLs, each "bound" to a different CLJ buffer, such that cider-switch-to-repl-buffer in CLJ buffer A moved cursor to REPL A, and in in buffer B moved cursor to REPL B. currently i find myself having to switch namespaces a lot more than i'd like.

zimablue 2021-07-06T06:19:14.251600Z

I have this question for two nrepls connected to the same buffer but not in the cider part, don't understand the nrepl part => does nrepl "broadcast" by default if two people connect to the same socket?

vinurs 2021-06-30T07:02:38.215300Z

i hava a java file HelloJava.java in src/java/main

package com.dieya.testjava;

public class HelloJava {

   public static String greetMe() {
      return "Hello, this is Java calling!";
   }

}
and set :java-source-paths ["src/java"] then in core.clj
(:import 
   (com.dieya.testjava HelloJava)
   )
but ,when i cider-jack-in-clj, it outputs
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Exception in thread "main" Syntax error compiling at (app/core.clj:1:1).
	at clojure.lang.Compiler.load(Compiler.java:7652)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6856.invoke(core.clj:6115)
	at clojure.core$load.invokeStatic(core.clj:6114)
	at clojure.core$load.doInvoke(core.clj:6098)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5897)
	at clojure.core$load_one.invoke(core.clj:5892)
	at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
	at clojure.core$load_lib.invokeStatic(core.clj:5936)
	at clojure.core$load_lib.doInvoke(core.clj:5917)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:5974)
	at clojure.core$load_libs.doInvoke(core.clj:5958)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:5996)
	at clojure.core$require.doInvoke(core.clj:5996)
	at clojure.lang.RestFn.invoke(RestFn.java:703)
	at user$eval140$loading__6737__auto____141.invoke(user.clj:1)
	at user$eval140.invokeStatic(user.clj:1)
	at user$eval140.invoke(user.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7181)
	at clojure.lang.Compiler.eval(Compiler.java:7170)
	at clojure.lang.Compiler.load(Compiler.java:7640)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:368)
	at clojure.lang.RT.maybeLoadResourceScript(RT.java:364)
	at clojure.lang.RT.doInit(RT.java:486)
	at clojure.lang.RT.init(RT.java:467)
	at clojure.main.main(main.java:38)
Caused by: java.lang.ClassNotFoundException: com.dieya.testjava.HelloJava
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:433)
	at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:586)
	at clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:466)
	at clojure.lang.RT.classForName(RT.java:2212)
	at clojure.lang.RT.classForNameNonLoading(RT.java:2225)
	at app.core$eval1595$loading__6737__auto____1596.invoke(core.clj:1)
	at app.core$eval1595.invokeStatic(core.clj:1)
	at app.core$eval1595.invoke(core.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7181)
	at clojure.lang.Compiler.eval(Compiler.java:7170)
	at clojure.lang.Compiler.load(Compiler.java:7640)
	... 34 more

vinurs 2021-06-30T07:03:02.215600Z

but in lein repl, it works ok

jumar 2021-06-30T10:42:17.216600Z

Do you have the class in the src/java/com/dieya/testjava directory?

vinurs 2021-06-30T16:31:53.217500Z

no, in src/java/main, and file HelloJava.java

jumar 2021-06-30T16:45:17.217700Z

So that's perhaps the problem? šŸ˜‰

vinurs 2021-06-30T17:00:48.217900Z

so ,the package name should be ?

vinurs 2021-06-30T17:00:57.218100Z

package testjava;?

vinurs 2021-06-30T17:09:12.218300Z

i put the file in src/java/main/com/dieya/testjava, named HelloJava.java, and in project.clj :java-source-paths ["src/java"]

vinurs 2021-06-30T17:09:27.218500Z

oh, is that i should remove the main directory?

vinurs 2021-06-30T17:13:45.218700Z

i put the file in src/java/com/dieya/testjavaļ¼Œ and in HelloJava.java

package com.dieya.testjava;

vinurs 2021-06-30T17:13:49.218900Z

but, the same error

jumar 2021-06-30T17:45:31.219100Z

The thing is that the package name should follow the directory structure. That is if you have java sources in src/java/ your HelloJava class is in the package com.dieya.testjava then the file should be src/java/com/dieva/testjava/HelloJava.java There might be some other problem but this is the basic convention that's followed in Java projects.

2021-06-30T17:55:55.220200Z

Is Cognitect actually not sponsoring CIDER or do I just not know how to list the sponsors properly? I'm asking because Calva lists Cognitect's sponsorship quite prominently on https://calva.io/ which makes it feel very official. :)

vinurs 2021-06-30T17:58:43.220400Z

strange, if i comment the

(:import (com.dieya.testjava HelloJava))
and cider-jack-in-clj, then uncomment the import code, it works

alexmiller 2021-06-30T18:26:19.221700Z

Cognitect is sponsoring at least Bozhidar, maybe others doing stuff for CIDER, see https://github.com/orgs/cognitect/sponsoring

ā¤ļø 1
alexmiller 2021-06-30T18:27:04.222100Z

that's not a complete list, there are also a few under nubank org and on Patreon

alexmiller 2021-06-30T18:29:23.222800Z

I'll feature CIDER in a future sponsorship spotlight on the Deref, feel free to tell me what the best list of people/projects is there

2021-06-30T18:32:11.224300Z

@alexmiller As always you're the best! :) I only noticed this because I jokingly posted in my shop whether anyone had considered moving away from Emacs now that Calva's out and VS Code is eating the world and someone immediately pointed out that Calva's sponsored by Cognitect as a serious plus and I went to go prove that CIDER was sponsored as well and came up empty. ĀÆ\(惄)/ĀÆ

2
alexmiller 2021-06-30T18:32:47.224600Z

we also buy a lot of IntelliJ Cursive licenses :)

2021-06-30T18:33:31.225700Z

Makes sense but I wouldn't even jokingly imply that someone would consider moving from Emacs to IntelliJā€¦ xD

alexmiller 2021-06-30T18:33:39.226200Z

I did :)

dpsutton 2021-06-30T18:34:09.227300Z

Thereā€™s a wealth of open source and proprietary clojure tooling. I am particularly happy when paid products can sustain people. Glad Colin has built such a great product

2021-06-30T18:34:48.228600Z

(If it's not clear I've got no beef with any set of tooling so long as it supports RDD. I'm being lighthearted here. :) )

alexmiller 2021-06-30T18:35:08.229Z

seriously though, I do a lot of Java interop and impl and IntelliJ is so good that it's worth it for that

ā˜ļø 1
pez 2021-06-30T18:35:48.230500Z

Calva is destilled CIDER. Just sayin' šŸ˜Ž

1
2
2021-06-30T18:36:49.231700Z

The first Clojure shop I ever worked had some decently serious Java components and we literally kept Eclipse around full time just for the job. I'm lucky (?) enough to write very little Java these days so on the very rare occasion that I jump into that space I still feel mostly happy from Emacs. I think if I did really serious work there I wouldn't have the option to stay away from an IDE. ĀÆ\(惄)/ĀÆ

alexmiller 2021-06-30T18:46:30.232100Z

many years ago, Cognitect funded Counterclockwise too :)

alexmiller 2021-06-30T18:49:11.232800Z

personally, I enjoyed Clojure on Netbeans the most, don't even remember what that was called now

2021-06-30T18:49:39.233100Z

These are deep cuts, Alex. :)

alexmiller 2021-06-30T18:50:25.233300Z

Enclojure!

dpsutton 2021-06-30T18:58:09.235500Z

Emacs as a dev environment and a production ready lisp weā€™re what got me into clojure. Now Iā€™m on the simplest inf-clojure setup. Just a few handy keybindings to call repl-provided tooling like doc and source

2021-06-30T19:03:03.235800Z

@dpsutton Did you ever give monroe a go?

dpsutton 2021-06-30T19:03:15.236100Z

i have not. i'l look into it

dpsutton 2021-06-30T19:03:40.236900Z

ah, it's nrepl. i'm staying away from nrepl this year. maybe i'll be back but digging it so far

2021-06-30T19:03:54.237100Z

I heard about years ago at this point from someone who said that CIDER had obfuscated one too many issues for them.

2021-06-30T19:04:13.237300Z

Nice.

2021-06-30T19:04:35.237800Z

What repl are you running in the inferior buffer?

dpsutton 2021-06-30T19:06:59.239200Z

socket repls err day. Absolutely lovely to connect locally to the repo or to a production jar and the tooling is identical

dpsutton 2021-06-30T19:07:31.239300Z

download a released jar, check out the code from that commit, socket repl java -jar the.jar with a socket repl command line addition

2021-06-30T19:08:08.239800Z

:grinning_face_with_star_eyes: Dev teaching you skills that directly translate to prod :grinning_face_with_star_eyes:

dpsutton 2021-06-30T19:10:40.240200Z

i think it is more built in tooling from Clojure is everywhere

dpsutton 2021-06-30T19:10:57.240700Z

and using the rich tooling built into the language and not relying on more means a jar and a repo are effectively the same dev environment

dpsutton 2021-06-30T19:11:17.241Z

how amazingly awesome that a production jar is queryable

2021-06-30T19:12:59.241200Z

Stunningly amazing. :)