nrepl

2025-02-26T17:58:45.113339Z

Hey! I'm developing the clojure-repl-intellij plugin, and have a question about the behavior of the cider-nrepl https://docs.cider.mx/cider-nrepl/nrepl-api/ops.html#refresh op. I have two files foo.clj and baz.clj (https://github.com/afucher/clojure-sample/tree/test-refresh-ns)

;;foo.clj

(defn some-function []
  "-foo")
;;baz.clj
(defn baz []
  (clojure-sample.foo/some-function))

(baz)

(clojure-sample.foo/some-function)
If I change the some-function to return -foz , call the op refresh and try to eval the function baz it returns the old value (`-foo`) but calling directly the function returns the new value
(baz) ;;=> "-foo"

(clojure-sample.foo/some-function) ;;=> "-foz"
If I evaluate the definition of baz or evaluate some-function again or load foo.clj file, it works. The behavior just happens after using the refresh op. Don't know if is some cache, or something related to var . Also, it was reproduced on emacs by @ericdallo

bozhidar 2025-03-10T05:39:20.353829Z

I haven’t looked at this part of the code in a while, but I recall it was a very thin wrapper around c.t.n/refresh (that’s where the name of the middleware and the op is coming from) https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/refresh.clj#L83 @arthurfucher can you file a ticket on cider-nrepl’s tracker and I’ll take a closer look.

👍 1
bozhidar 2025-03-10T05:41:57.219749Z

This probably needs to be checked more carefully as well https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/refresh.clj#L19

2025-03-10T11:19:19.240519Z

@bozhidar issue created: https://github.com/clojure-emacs/cider-nrepl/issues/918 Let me know if I can help with anything

👍 1
ericdallo 2025-02-28T17:12:36.429619Z

@bozhidar any idea? We tested Cursive and saw it works but I think it does in its own custom way, not using refresh ops