Fork me on GitHub

I'm trying to learn cider, and I'm a little confused about the cider-refresh function. I'm expecting that I can add, say, a defn to my user namespace in dev/user.clj, save the file, call cider-refresh, and my fn will be available in the repl buffer. But that doesn't happen. Is my expectation correct, or have I misunderstood what cider-refresh is intended to do?


you probably want something more along the lines of eval buffer or eval defun. Cider-refresh is more of a refresh the repl and a blank slate kind of deal rather than incremental loading of code changes.


You say it's a blank slate kind of deal…is it supposed to wipe out vars that you defined in the REPL but not in the dev/user.clj file?


yes i believe so


it should reload the user.clj file if that file is on the classpath and the current ns or required by the current ns... i think


my most used commands are C-M-x for eval top level defun and C-u C-c M-z to load the current buffer and switch to that namespace


Thanks for walking me through it…what do you mean by "top level defun"? Like the last defn in a file? Or the ns at the top? Or what?


I must be doing something wrong. I add a defn to my dev/user.clj file, then cider-refresh, then type the new fn name at the REPL (not even trying to call it, just print it), and it tells me Unable to resolve symbol.


Also, the old defs that I typed into the REPL buffer but which aren't in the dev/user.clj file are still around.


When I call cider-refresh I see cider-refresh: Reloading successful in my status line and Reloading successful in my *cider-refresh-log* buffer. So it seems like it's reporting success, but it's not doing what I expect.


So I conclude that either my expectations or my usage of cider are incorrect. simple_smile


The cider docs [1] say that cider-refresh wraps, which maybe doesn't answer my question directly but it does lead me to think that what you said above is correct, that it should wipe out the repl state and reload purely from what's in the dev/user.clj file.


i'm not too familiar with dev/user.clj is that a boot thing?


why aren't you in core.clj of your project?


@jeff.terrell you might want to read up on the reloaded workflow by stuart sierra. the user.clj file and the user ns is somewhat special... I don't think it is a cider thing but rather as you found out already a tools.ns thing


Hi! We have custom deftest* macro in our codebase. And we are unable to run such tests with cider. cider-nrepl receives * as var name. Problem is in this regexp -> Can anyone help me to improve this regexp?


Ah, figured it out. @benedek was right, I hadn't set up my project the way that Stuart Sierra recommended in his "workflow reloaded" blog post [1]. I was missing this from my defproject:

:profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace "0.2.3"]
                                  [org.clojure/java.classpath "0.2.0"]]}}
Now I can reload to my heart's content. Thanks @dpsutton and @benedek for the help! [1]


a related idea, cider could have a reload mode where it auto injects these dependencies


or a defcustom to do so


it shouldn't need to, it brings it's own tools.namespace :thinking_face:


Yeah, I just tried it without the :dependencies from the snippet above (in other words my :dev profile is simply {:source-paths ["dev"]}, and it worked fine. So that's good.


There's still that manual step I have to take to add the source path, but I think it's understandable that not everybody would want to have the dev/ directory in their source path simply by virtue of using cider. simple_smile


@jeff.terrell ah, so your file wasn't on the classpath. That makes sense now.


I’m starting a cljs-repl with boot and then using cider-connect but cider doesn’t seem to recognize that repl as a cljs one


try (setq cider-repl-type "cljs")


no idea if that will work but this is the mechanism that determines what kind of repl you are in


see cider-repl--state-handler for details. but after every repl interaction it gets a state of what namespace its in and what type of repl its in. not sure if this will persist.


apologies if I’m not the first to ask about this, but how can I resolve

Possibly confusing dependencies found:
[org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]
[cider/cider-nrepl "0.15.0"] -> [org.clojure/tools.nrepl "0.2.13" :exclusions [org.clojure/clojure]]

Consider using these exclusions:
[cider/cider-nrepl "0.15.0" :exclusions [org.clojure/tools.nrepl]]

Aborting due to :pedantic? :abort
I got this as soon as I upgraded from Cider 0.14.0 to 0.15.0.


Even if I add the exclusion as suggested, it still throws that error.


My profiles.clj now looks like

{:user {:plugins [[lein-monolith "1.0.1"]
                  [mvxcvi/whidbey "1.3.0" :exclusions [mvxcvi/puget]]
                  [lein-cljfmt "0.5.5"]
                  [lein-cprint "1.2.0"]]
        :dependencies [[mvxcvi/puget "1.0.1"]]}
 :my/repl ^:repl
 {:plugins [[cider/cider-nrepl "0.15.0" :exclusions [org.clojure/tools.nrepl]]
            [refactor-nrepl "2.2.0"]]}
 {:injections [(require 'pjstadig.humane-test-output)
  :dependencies [[pjstadig/humane-test-output "0.7.1"]]}}


and my project has :pedantic? :abort