Fork me on GitHub
#cursive
<
2017-01-03
>
bfabry20:01:52

@cfleming decided to try out that exception debugging fancyness, and got some unexpected behaviour. function locals seem to be null?

cfleming20:01:09

@bfabry It’s probably locals clearing doing that, which can be tricky. Are you AOTing your code?

bfabry20:01:31

it's running in debug mode with the little thingy at the top saying "locals will not be cleared"

bfabry20:01:09

nope as in no aot sorry, that was unclear

cfleming20:01:30

If you enter *compiler-options* in your REPL, what does it show?

bfabry20:01:02

*compiler-options*
=> {:disable-locals-clearing true}

cfleming20:01:17

Seems pretty conclusive 🙂

cfleming20:01:42

So the tricky thing is that that option takes effect when Clojure is compiling code, not when the code is executed.

cfleming20:01:01

If you reload the namespace which has the problem and then try again, does that help?

bfabry20:01:26

interesting. it was a fresh repl and loaded namespace, it's the first time I've started the repl in debug mode

bfabry20:01:31

reloading it did fix it

bfabry20:01:48

lemme check something

cfleming20:01:06

Sure. Do you have code loading in your REPL using injections, or something?

bfabry20:01:24

I don't think so...

cfleming20:01:57

I’ve seen this myself sometimes, but I haven’t investigated because I AOT code and I thought that was the issue. I’ll have to check that again.

cfleming21:01:03

Back in a moment

bfabry21:01:20

I'm guessing it's getting required in by my custom user.clj, which is compiled prior to that option being set

bfabry21:01:40

yup, that's it

bfabry21:01:10

god dammit, the whole clojure core loading user.clj early has screwed me over like 3 times in the last few months

bfabry21:01:41

now I've gotta try and remember the jira issue for that thing again

bfabry21:01:13

ARGH and now I'm mad at ME because I found the commit where I last encountered this and it just says "work around clojure bug" without a link to the friggen bug!

cfleming21:01:55

I hate that - I just spent a bunch of time tracking down a bug which I had solved previously, but the commit message didn’t help at all.

bfabry21:01:13

user.clj is loaded prior to anything else

bfabry21:01:37

last time my issue was that it's loaded prior to javac running, meaning if your project includes java code it blows up with class not found exception

bfabry21:01:56

new issue is that it gets loaded prior to your locals clearing var being set

bfabry21:01:44

aight, well, I don't know why I bothered tracking that down because it seems basically unsolvable. no doubt changing the load time of user.clj would break so many things. I just need to remember not to require things in there

cfleming21:01:12

I’ll check to see if I can inject before that point somehow.

bfabry21:01:19

kind of frustrating. it's useful to require things in there. seems like that namespace/file is serving double purposes

cfleming21:01:52

Assuming user.clj is only used for dev, you could actually set the compile flag in there.

cfleming21:01:29

(alter-var-root #'*compiler-options* assoc :disable-locals-clearing true)

cfleming21:01:56

You’ll get occasional OOMs if you hold onto seqs, but during dev that’s not an issue.

cfleming21:01:36

IIRC you can also set those flags via system properties which might be an option, but I’d have to look at the code again to be sure.

cfleming21:01:53

And also to ensure that they get set before user.clj is loaded.