Fork me on GitHub
#cider
<
2019-04-27
>
deep-symmetry04:04:19

Does anyone know why Cider no longer honors the :init-ns setting in the :dev profiles of my Leiningen projects when I jack in? This used to work, and if I open a repl in Leiningen directly, with no Cider involvement, it puts me in the namespaces I expect. But Cider now is only putting me in the user namespace, which means none of the convenience functions (like doc, etc.) are available, because Leiningen put them in the project’s configured initial namespace.

;; Connected to nREPL server - 
;; CIDER 0.21.0 (New York), nREPL 0.6.0
;; Clojure 1.10.0, Java 1.8.0_181

deep-symmetry04:04:28

And my Leiningen version is 2.9.1.

dpsutton14:04:14

@deep-symmetry can you help me reproduce the happy path? i've made a lein project fizzbuzz with fizzbuzz.core and in project.clj i put :init-ns fizzbuzz.core. Presumably if I do lein repl i end up in user with not CIDER involvement. I've tried lein versions 2.9.1, 2.8.1 and 2.7.1

deep-symmetry17:04:42

The easiest way would probably be to point you at one of my Clojure repositories. Dysentery has the fewest external dependencies and exhibits the problem: https://github.com/Deep-Symmetry/dysentery

deep-symmetry17:04:41

If I clone that repo, then run lein repl within it, I am placed in the dysentery.core namespace as expected. But if I use CIDER to jack in to the project, I am placed in a stunted user namespace instead.

dpsutton17:04:29

Which version of Leon?

dpsutton17:04:15

Ah it’s under repl options. Thanks. I’ll look after lunch

dpsutton17:04:25

I was doing it top level

dpsutton18:04:51

@deep-symmetry annoyingly, it works for me with lein 2.9.1 and using CIDER from master which is 0.22.0-snapshot. Can you try something for me? Change the welcome function in the project.clj file to

:welcome (do (println "dysentery loaded.")
             (println (.name *ns*))
             (System/exit 0))
and then run lein update-in :dependencies conj \[nrepl\ \"0.6.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.22.0-SNAPSHOT\"\] -- repl that for prints out its in the correct ns with CIDER loaded. I'm guessing it will be the same for you

dpsutton18:04:14

if this tests pass, i'm thinking something other than main CIDER is doing this. do you have refactor in the mix? any other packages?

deep-symmetry20:04:13

You are correct, that did print the correct namespace (and then the transport socket closed because of the System/exit invocation). Ok, I do have clj-refactor in the mix, and this would not be the first time it has caused me grief.

deep-symmetry20:04:50

But I just uninstalled clj-refactor and I am still ending up in user when jacking in.

deep-symmetry20:04:15

OK, I just un-pinned CIDER from melpa-stable, and I can confirm that the version from master has fixed this problem. Now I just have to decide if I want to risk staying on the bleeding edge, or wait until this gets a stable release.

deep-symmetry20:04:49

And it still works with clj-refactor enabled. I guess I will try living on master for a while.

deep-symmetry20:04:48

Thanks for the suggestions and help experimenting!