Fork me on GitHub
#cursive
<
2018-08-24
>
kenny00:08:09

I have a user.clj on the classpath that does this:

(ns user
  (:require
    [clojure.spec.alpha :as s]
    [expound.alpha :as expound]))

(set! s/*explain-out* expound/printer)
When I start a REPL I get this:
Exception in thread "main" java.lang.ExceptionInInitializerError
	at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *explain-out* with set, compiling:(user.clj:6:1)
	at clojure.lang.Compiler.load(Compiler.java:7526)
	at clojure.lang.RT.loadResourceScript(RT.java:379)
	at clojure.lang.RT.loadResourceScript(RT.java:366)
	at clojure.lang.RT.maybeLoadResourceScript(RT.java:362)
	at clojure.lang.RT.doInit(RT.java:482)
	at clojure.lang.RT.<clinit>(RT.java:336)
	... 1 more
Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *explain-out* with set
	at clojure.lang.Var.set(Var.java:223)
	at user$eval708.invokeStatic(user.clj:6)
	at user$eval708.invoke(user.clj:6)
	at clojure.lang.Compiler.eval(Compiler.java:7062)
	at clojure.lang.Compiler.load(Compiler.java:7514)
Any idea why? Perhaps because the nREPL hasn't connected yet?

cfleming01:08:58

@raymcdermott There’s nothing lein-specific about it, but it does rely on nREPL (for the moment). If you use a clojure.main REPL it won’t work, but if you use “Use nREPL in normal JVM process” it should work.

😎 1
cfleming01:08:35

@kenny I’m not sure - do you get that running it outside Cursive as well? Is that with deps or lein?

cfleming01:08:53

I don’t think it’s anything to do with nREPL.

alexmiller02:08:27

s/*explain-out* is a dynamic variable. to be able to set! it, it must have been bound in a binding somewhere higher on the stack. The clojure.main repl does this, nrepl does not.

alexmiller02:08:41

in some cases (alter-var-root #'s/*explain-out* (constantly expound/printer)) may work better for you

cfleming07:08:06

@alexmiller Interesting, thanks for the explanation.

cfleming07:08:49

That sounds like it should be simple to fix in nREPL, at least.

raymcdermott09:08:32

@cfleming I must have missed the news that you can use a standard nREPL with a deps.edn project. Thanks - it’s working great again

alexmiller11:08:08

deps.edn can be used to run Clojure programs and an nrepl client is just a program

llsouder12:08:34

Anybody have some "standard" keybinding for cursive?

llsouder12:08:09

I am using the vim plugin too, maybe I should switch back to intellj mode?

llsouder12:08:05

and just deal with all the "j"s and "k"s I accidentally type 🙂

sgerguri12:08:34

@llsouder I mostly use the defaults, with a few extra mappings and some remapped to avoid conflicts on MacOS; I also use the Vim plugin, and that's how I tend to navigate - I don't use the sexpr-jumping chords. I find that it works well.

llsouder12:08:42

@sgerguri what functions are you mapping in your "extra mappings"?

sgerguri13:08:25

Just those that are REPL-related - switching between REPL and editor window, reloading and syncing, sending form under caret for eval (though the last one might just be mapped by default). I also have test integration set up, but again that might be coming in through the default settings. I haven't changed things in there in a long time, and the Keymap has improved dramatically compared to what the situation was just a couple of years ago.

raymcdermott14:08:59

@alexmiller - yeah, sorry I meant specifically nREPL with #cursive

onetom16:08:17

@cfleming how the classpath is being calculated for the local nREPL and clojure.main run configurations in a deps project?

onetom16:08:09

btw, in the clojure.main case, the -classpath is not double-quoted, but in the nREPL case it is. i just noticed it when i copy-pasted the repl command lines into a scratch and it got syntax-highlighted differently

onetom16:08:28

nREPL case:

/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=55773:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk-10.0.2
...
:/Users/onetom/Library/Application Support/IntelliJIdea2018.2/clojure-plugin/lib/tools.nrepl-0.2.12.jar" clojure.main -i /private/var/folders/5m/ssz2l6_n7z74d31b2q5wbfl00000gn/T/form-init5295767744484685351.clj

onetom16:08:52

clojure.main case:

/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=56747:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk-9.0.1
...
:/Users/onetom/.m2/repository/org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar clojure.main -r

onetom16:08:20

just saying, because maybe the clojure.main case might need some shell escaping... unless there is some magical reason why are they quoted differently

dpsutton17:08:38

question for a coworker: how can one prevent cursive from indexing a really big edn file? He's getting stack overflow errors

manutter5117:08:05

maybe move it into its own folder, then right click the folder and select Mark Directory As -> Excluded — probably not ideal, but I believe that will work

dpsutton17:08:07

ah it's by directory, not file?

manutter5117:08:51

Yeah it took me almost a year to figure out I could Exclude the logs directory. “Find In Project” is a LOT less spammy now.

dpsutton17:08:14

awesome. we were looking around in context menus but always by file and not on the directory. thanks a bunch

👍 1
dealy20:08:31

Hi I recently upgraded intellij to the latest version and I can no longer see the leiningen tool window, nor run my clojure project. I'm running cursive 1.7.0-2018.2 and leiningen plugin 0.0.3. Any ideas?

manutter5120:08:30

Maybe try File -> Invalidate Caches & Restart?

dealy20:08:53

think i tried that already, but will try again

manutter5120:08:27

Wait, Leiningen plugin? Cursive does its own lein stuff, you shouldn’t need a separate plugin and I would think having one might be a problem

dealy20:08:49

hrmmm, could be I noticed that the plugin is very old

manutter5120:08:06

Yeah, I’m pretty sure you want that one turned off

dottedmag20:08:45

I see rebel-readline in classpath for REPL, but I can't figure where it comes from. The project is deps.edn one, and I do have rebel-readline-cljs in :extra-deps for some of the aliases, but not in default :deps.

cfleming20:08:46

@dpsutton Wow, that must be a big file.

dpsutton20:08:14

1 sec i'll tell you

cfleming20:08:27

Is it very deep, i.e. lots of structures nested to a really deep level? I’d be interested to see the stacktrace for the SOE

cfleming20:08:12

@dealy Yes, you have to remove the Leiningen plugin, it’s very old and Cursive’s support is much more sophisticated (and was based on that plugin a long long time ago, with the authors’ blessing).

cfleming20:08:44

@dottedmag You can see the dependency tree in the deps toolwindow so you can see how it’s being pulled in.

dpsutton20:08:45

5600 lines of #:db{:ident :breeze.Immunization/status, :valueType #:db{:id 20}, :cardinality #:db{:id 35}} and similar

dpsutton20:08:47

less than a meg

cfleming20:08:17

@dpsutton That should definitely not provoke an SOE.

dpsutton20:08:26

my coworker agrees 🙂 lol

dpsutton20:08:45

yeah we were surprised to see a stack overflow on it

dpsutton20:08:53

it's not heavily nested to my knowledge

cfleming20:08:17

If you could email a copy of the SOE stacktrace, it would be much appreciated. Is it possible that the SOE was actually provoked by some other file in the project, especially a CLJC one?

dpsutton20:08:36

i'm not sure we chased that thread

dpsutton20:08:45

what's preferred?

cfleming20:08:48

There’s at least one SOE fixed in the latest EAP - are they on the EAP or the latest stable?

dpsutton20:08:58

stable i think

dottedmag20:08:04

@cfleming Oh, I see some of aliases checked, but I don't remember checking them. Thanks.

cfleming20:08:28

@dpsutton Ok, if they switch to the EAP that might be fixed.

cfleming20:08:16

@onetom I’m not sure about the quoting, it’s IntelliJ that actually constructs the classpath - I use an API to set the elements and then it constructs. It’s usually right, but I don’t always understand its reasons 🙂

dealy21:08:29

@cfleming thanks, yea removing the old plugin did the trick