Fork me on GitHub
#cider
<
2017-08-01
>
jeff.terrell01:08:06

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?

dpsutton01:08:51

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.

jeff.terrell01:08:18

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?

dpsutton01:08:20

yes i believe so

dpsutton01:08:44

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

dpsutton01:08:47

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

jeff.terrell01:08:51

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?

jeff.terrell02:08:09

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.

jeff.terrell02:08:57

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

jeff.terrell02:08:44

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.

jeff.terrell02:08:18

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

jeff.terrell02:08:47

The cider docs [1] say that cider-refresh wraps clojure.tools.namespace, 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.

dpsutton03:08:53

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

dpsutton03:08:07

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

benedek07:08:20

@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

ponimas11:08:14

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 -> https://github.com/clojure-emacs/clojure-mode/blob/da758ae3a089b8e8961958ecdf58ee94d9bd8746/clojure-mode.el#L1734 Can anyone help me to improve this regexp?

jeff.terrell15:08:59

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] http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded

richiardiandrea15:08:57

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

richiardiandrea15:08:13

or a defcustom to do so

dominicm15:08:46

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

jeff.terrell15:08:51

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.

jeff.terrell15:08:41

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

dominicm15:08:14

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

jfntn18:08:10

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

dpsutton18:08:35

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

dpsutton18:08:51

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

dpsutton18:08:28

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.

aengelberg21:08:02

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]]
 overrides
[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.

aengelberg21:08:22

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

aengelberg21:08:05

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"]]}
 :humane
 {:injections [(require 'pjstadig.humane-test-output)
               (pjstadig.humane-test-output/activate!)]
  :dependencies [[pjstadig/humane-test-output "0.7.1"]]}}

aengelberg21:08:22

and my project has :pedantic? :abort