Fork me on GitHub
#cider
<
2021-09-17
>
jmckitrick16:09:28

Hey all, I'm trying to install refactor-nrepl into a project using deps.edn . I have it in the :extra-deps section just below cider-nrepl and I see it loading during startup, but...

jmckitrick16:09:32

'user-error: The refactor-nrepl middleware isn’t available! Did you remember to install it?'

vemv20:09:59

hi! one thing is adding the dep, another is starting a nrepl server with the cider-nrepl middleware and refactor-nrepl middleware in it have you tried something like that? Or is your use case different?

vemv21:09:41

btw I cut https://clojars.org/refactor-nrepl/versions/3.0.0-alpha1 just now. It bundles all these: https://github.com/clojure-emacs/refactor-nrepl/blob/1399da2029c2e875d450af4caa347302f55fa965/CHANGELOG.md#unreleased they're all much-needed performance and reliability improvements, no new features / breaking changes. I'd much recommend using this one.

jmckitrick21:09:03

Thanks for the help! First question: since I'm using deps.edn and mostly maven artifacts, how long does it take to propagate?

jmckitrick21:09:41

I have CIDER working just fine, with the cider-nrepl middleware working very well.

vemv21:09:04

I've never perceived a propagation delay for regular Maven dependencies

jmckitrick21:09:08

But I have not done anything in code to start the refactor-nrepl

jmckitrick21:09:58

My mistake, I changed the wrong version number 😉

vemv21:09:52

> I have CIDER working just fine, with the cider-nrepl middleware working very well. how do you start cider / cider-nrepl?

jmckitrick21:09:39

I run the app from the command line, then in emacs cider-connect-clj

jmckitrick21:09:52

WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.1 (package: 20210628.1154) and n/a, respectively.

jmckitrick21:09:00

That's the message I get in the repl after connecting

vemv21:09:28

in case it helps, the typical pattern is

(let [handler (refactor-nrepl.middleware/wrap-refactor cider.nrepl/cider-nrepl-handler)]
  (nrepl.server/start-server :port port :handler handler))

vemv21:09:59

the WARNING can be ignored, it's normal that they're out of sync (you are precisely using a custom version)

jmckitrick21:09:39

So starting the app with clojure -M:dev gives an error:

jmckitrick22:09:14

`Syntax error (ClassNotFoundException) compiling at (my-project-name/dev.clj:36:17). refactor-nrepl.middleware`

vemv22:09:42

trying, give me 3m

jmckitrick22:09:59

However, if I comment out the offending code, start the app, then C-c C-c the file in cider, it compiles ok.

jmckitrick22:09:17

I'll have to dig into it a bit later, and let you know what I find.

vemv22:09:22

$ clj
Downloading: refactor-nrepl/refactor-nrepl/3.0.0-alpha1/refactor-nrepl-3.0.0-alpha1.pom from clojars
Downloading: refactor-nrepl/refactor-nrepl/3.0.0-alpha1/refactor-nrepl-3.0.0-alpha1.jar from clojars
Clojure 1.10.3
user=> (require 'refactor-nrepl.core)
nil

vemv22:09:43

> ClassNotFoundException gonna state the obvious, you have to require these namespaces. my snippet was maybe a little too terse

jmckitrick01:09:23

That’s probably it. When experimenting on code, I often just use the full namespace at the place of reference until I decide I want to keep the code. I guess that causes problems here.

jmckitrick02:09:16

I’ll try and report back later.

vemv04:09:01

after many attempts, alpha10 is finally a decent release. I also recommend setting:

(cljr-ignore-analyzer-errors t)
if using Emacs. Feel free to report away any found stacktraces (those are typically printed to *messages*), can fix quite quickly

jmckitrick12:09:33

Ok, I’ll give that a shot.

jmckitrick12:09:01

I'm up and running! I needed refactor-nrepl.middleware in the require section.

vemv18:09:04

cool! happy to hear! I have some alphas to release this week, since some features remain with the same quirks they have over the years. It's partly easy - a matter of upgrading our awesome https://github.com/clj-commons/rewrite-clj dep :)