Fork me on GitHub
#cursive
<
2021-11-10
>
Kari Marttila13:11:27

Occasionally I have some annoying issue using Cursive which I just haven't been figured out what I am doing wrong. I have a Clojure REPL running in a terminal. I connect to this backend RELP using Cursive Run configuration: nREPL. Everything is working just fine. Occasionally I want to experiment with some function X in namespace Y. I change REPL to this namespace (using Switch REPL NS to Current File) and *ns* shows that I'm in namespace Y). Now I load everything in the editor (in namespace Y) into REPL (`Load File in REPL`). I have a comment block. In comment block I have some test data. Now I evaluate the test data. Then I call some function X in that namespace with that test data. Everything works fine. I experiment more. Suddenly the same function X call with the same data gives me error, e.g.:

Execution error (IllegalArgumentException) at y/x .
Don't know how to create ISeq from: clojure.lang.Var$Unbound
If I evaluate the function X, and the test data separately, I can see that there is a binding. At this point I don't restart the terminal REPL, but I click the Restart REPL button in the Cursive REPL window. I once again switch REPL to this namespace Y and load everything in the editor into REPL. Everything works once again just fine. This is a bit annoying. I'm 99% sure this is not a Cursive bug but I have something wrong in my work flow. I'd appreciate any help how to investigate what is happening in my workflow and how to fix this issue.

Kari Marttila13:11:09

The rubber duck effect works. I just now realized after writing this that I might have unconsciously hit my Integrant-reset hot key in my laptop. This probably causes this. I need to investigate this a bit. But if you have some hints I'm happy to hear about them! 🙂

Kari Marttila13:11:03

I just managed to get this error after hitting my Integrant reset button. But the weird thing is that

(keys (ns-publics *ns*))
Shows the same bindings before and after the Integrant reset, but after the reset I get this clojure.lang.Var$Unbound error. I have done a few years Clojure development but I'm not a Clojure guru. I asked about this in the Metosin slack and someone said that he remembers to experience something similar which was a bit weird.

henryw37414:11:39

if you do switch to ns again, does that fix it?

Kari Marttila14:11:28

No. And the weirdist thing is that this does not happen immediately after hitting Integrant reset - possibly it has nothing to do with it.

Kari Marttila14:11:48

Unpleasent to debug this since it behaves as if there is some non-deterministic behaviour, even though my brain says that it cannot be non-deterministic.

henryw37414:11:39

what came to mind is if doing a clojure.tools.namespace.repl/refresh, the ns gets removed and recreated. wondered if somehow you had a stale reference to deleted var

Kari Marttila14:11:05

Possibly something like that.

onetom15:11:44

i also tried to mix the usage of ctnr/refresh with the cursive load file / sync files in repl and ended up with inexplicable situations. but when i work with defprotocols or deftypes, it would be really nice to be able to unload the NSes with those definitions and reload every other NS, which used the previous definitions of those protocols and types. alternatively, it would be good to have some guides about how to structure a program, which relies on these abstractions, in way, that makes it easy to develop them. im still not sure i comprehend everything in https://functionalbytes.nl/clojure/lifted/protocols/2020/06/11/lifted.html for example, but i have the feeling, it might help with my issues... :/

Colin P. Hill15:11:06

One of spec's value propositions is that fdef adds information to the docs generated for a function, but Cursive's documentation popups don't seem to incorporate this information. Are there plans to add this?

2
cfleming00:11:23

Yes, Cursive should definitely do this.