Fork me on GitHub
#cider
<
2018-05-10
>
bozhidar05:05:16

Well, I’d really love it for us to fix this. In the mean time I’ve added a section in “Troubleshooting” about refactor-nrepl, which probably no one read. 🙂

bozhidar05:05:47

The problem is that refactor-nrepl does this injection, not CIDER. I think the simple solution would be for refactor-nrepl to check the CIDER version before injection itself and just skipping this injection for incompatible versions.

bozhidar05:05:35

Anyways, my involved in the refactor-nrepl project is almost 0, which is another reason for this state of affairs. I would have synched the releases, but I don’t have time for more projects.

bozhidar05:05:15

@bhauman We don’t have dep injection for cljs, as it’s a bit more involved. Currently the code is written in a way that you get asked about the REPL to start fairly late in the init process and because of this you don’t really know what to inject (after a clj REPL has already started). Another nice way to solve this would be to add some hotloading functionality to CIDER, so you’d be able to add the cljs deps after you’ve started a clj REPL.

bozhidar05:05:48

@benedek Is this functionality in refactor-nrepl complex? Would it be feasible to move it?

benedek06:05:27

well it is not that bad as it leans on a dependency, alembic to do the heavy lifting. but alembic is unmaintained not compatible with java9 +

dominicm06:05:40

There's a function in tools deps alpha that does it now

dominicm06:05:55

I would guess it works with 9

benedek06:05:00

And you also need to retriebe libs you want to load via http i guess

benedek06:05:14

Seen that @dominicm

benedek06:05:32

My plan is to rewrite it the feature

benedek06:05:48

Could go to cider but yeah it is pretty complex

benedek06:05:10

Sorry for the typos. On my phone

bozhidar06:05:50

@dominicm I also saw this feature and I was wondering whether we can just take this and stuck into some middleware.

bozhidar06:05:35

I find it odd that adding libs at runtime is still not a solved problem in Clojure after all those years.

dominicm06:05:14

I thought it was? Chas' library offered this functionality for maven

benedek06:05:00

You mean alembic, right?

dominicm06:05:18

Just call the add class path function

bozhidar06:05:13

But this stopped working Java 9+.

bozhidar06:05:19

(the classloader changes)

bozhidar06:05:28

I think this is what @benedek referred to.

dominicm07:05:19

I don't understand the problem yet. TDA just uses the closest Clojure dynamic class loader. Why don't people running cider have one of those?

arrdem07:05:57

Clojure's addUrl is private and I think always has been.

bozhidar07:05:01

All the code I’ve seen for dynamic loading libraries used an URLClassLoader.

arrdem07:05:20

Previously reflection was used to hack it public, which stops working in 9/10.

arrdem07:05:07

Boot and some other things have their own bootstrap runtimes precisely to inject their own dynamic class loader as high as they can.

arrdem07:05:41

At least that's my understanding from some poking at this issue and build tooling

bozhidar07:05:06

I haven’t played with that much, I just know what we were doing got fucked up recently. 🙂

dominicm07:05:58

The one in Clojure seems public https://github.com/clojure/tools.deps.alpha/compare/add-lib doesn't seem too complex

bozhidar07:05:46

But I seemed to recall it (currently) doesn’t work with nREPL properly (or something like this).

bozhidar07:05:15

Probably because of a different classloader hierarchy.

dominicm07:05:28

I suspect we will need to look there to find a solution then.

benedek08:05:04

yup, this issue starts with researching this a bit i suppose. and checking out in detail what the core team is coming up with re. @dominicm and clj tooling support for this

bozhidar08:05:20

True. So, did I get this right - @dominicm is our volunteer to research this? 😉

dominicm08:05:04

Pretty much 🙂

dominicm08:05:06

That's fine by me though.

benedek08:05:16

hahaha, that would be super nice. i intend to do the same if I by same luck/miracle get some time for it

benedek08:05:41

so @dominicm would be very grateful here if you have/time energy

dominicm08:05:29

You've given me a puzzle now, there's no way I'm not going to figure it out

bozhidar09:05:35

@dominicm Good man! 🚀

dominicm10:05:32

if it is an nrepl problem, then t.d.a.r/add-lib wouldn't work with nrepl

dominicm10:05:40

tdar sounds like ta-da

bozhidar11:05:36

I don’t what problems is it or if there’s even a real problem - just remember seeing some Twitter thread after Alex Miller announced this feature.

benedek13:05:46

this is what we are talking about, right?

benedek13:05:07

wonder if this works under java9+ at all…

benedek13:05:20

tools.deps.alpha is tested on openjdk 9 so i guess it should work

benedek13:05:35

but it is all down to the classloader hierarchy really…

bhauman14:05:04

@bozhidar it seems like it would be safe to add piggiback to the deps and place it in the middleware if a cider-jack-in-cljs is called. Simply because its a no-op until you execute the piggie/cljs-repl call

bhauman14:05:59

It's only extra dependency is clojurescript ... and that is required anyway

bhauman14:05:33

isn't there only one repl (shadow) that doesn't need it?

bozhidar14:05:54

Yeah, that’s easy - I was mostly referring to what to do with the actual deps like figwheel. Ideally we’d have to change the current logic now to first ask for the actual cljs REPL to run, inject all the deps, start and convert the clj REPL.

bhauman14:05:22

oh I'm not talking about requiring figwheel

bhauman14:05:33

but I what you are saying

bozhidar14:05:18

> isn’t there only one repl (shadow) that doesn’t need it? Yeah, it doesn’t use it, but probably it won’t be a problem to have it around regardless.

bhauman14:05:05

I think getting piggieback in there early would be a big boon, and would get rid of the complexity here: https://cider.readthedocs.io/en/latest/clojurescript/

bhauman14:05:23

Also, I'd love to know how to decorate cljs errors so that you can get line, column and stack info. I can make an issue on piggieback?

bozhidar14:05:02

> I think getting piggieback in there early would be a big boon, and would get rid of the complexity here: https://cider.readthedocs.io/en/latest/clojurescript/

bozhidar14:05:28

I agree. It’s not a complete solution, but it’s a good (and simple first step).

bozhidar14:05:35

> Also, I’d love to know how to decorate cljs errors so that you can get line, column and stack info. I can make an issue on piggieback?

bozhidar14:05:03

Sure. Basically you just have to get them in the same format as the Clojure errors in terms of line structure.

bhauman14:05:47

You mean format the error message text.

bozhidar14:05:11

Yeah, exactly.

bozhidar14:05:31

How do they look right now?

bhauman14:05:18

oh they are all over the place, as there are many different kinds and it depends on the context

bhauman14:05:56

I have a way to turn them into data

bozhidar14:05:58

(defun cider-extract-error-info (regexp message)
  "Extract error information with REGEXP against MESSAGE."
  (let ((file (nth 1 regexp))
        (line (nth 2 regexp))
        (col (nth 3 regexp))
        (type (nth 4 regexp))
        (pat (car regexp)))
    (when (string-match pat message)
      ;; special processing for type (1.2) style
      (setq type (if (consp type)
                     (or (and (car type) (match-end (car type)) 1)
                         (and (cdr type) (match-end (cdr type)) 0)
                         2)))
      (list
       (when file
         (let ((val (match-string-no-properties file message)))
           (unless (string= val "NO_SOURCE_PATH") val)))
       (when line (string-to-number (match-string-no-properties line message)))
       (when col
         (let ((val (match-string-no-properties col message)))
           (when val (string-to-number val))))
       (aref [cider-warning-highlight-face
              cider-warning-highlight-face
              cider-error-highlight-face]
             (or type 2))
       message))))

bhauman14:05:13

well thats helpful

bozhidar14:05:23

That’s the code in CIDER that processes errors/warnings and maps them to the source buffers.

bozhidar14:05:47

And that’s the regexp:

(defvar cider-compilation-regexp
  '("\\(?:.*\\(warning, \\)\\|.*?\\(, compiling\\):(\\)\\(.*?\\):\\([[:digit:]]+\\)\\(?::\\([[:digit:]]+\\)\\)?\\(\\(?: - \\(.*\\)\\)\\|)\\)" 3 4 5 (1))
  "Specifications for matching errors and warnings in Clojure stacktraces.
See `compilation-error-regexp-alist' for help on their format.")

bozhidar14:05:04

(which we can obviously change if we have to)

bhauman14:05:42

would it be a bad idea to have a data protocol?

bhauman14:05:15

where we send this info directly, and then fall back to parsing the string?

bhauman14:05:32

I'm sure that's a bigger change

bozhidar14:05:19

A data protocol would certainly be preferable - when I was starting out I was limited by the fact that no one wanted to make changes neither on Clojure or nREPLs side. 🙂 (and we didn’t use middleware back then)

bhauman14:05:32

I totally get you there

bhauman14:05:58

there is also Throwable->map which is interesting

dpsutton14:05:19

is there any word on getting nrepl under the clojure-emacs team?

deg14:05:37

I've just created a new project (Luminus template +cider etc.). I updated the cider dep to 0.17.0 and jacked in from a ClojureScript file. I updated all my Emacs packages. I'm getting "WARNING: CIDER's version (0.17.0-snapshot) does not match cider-nrepl's version (0.17.0). Things will break!" I can't see who is loading the snapshot version.

deg14:05:56

Hmm, in [Messages] I see "Starting nREPL server via lein update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.17.0-SNAPSHOT\"\] -- repl :headless :host ..."

dpsutton14:05:51

You could try lein deps to see if that explains anything. Traditional culprits are profile.clj

dominicm15:05:25

@benedek Clojure adds a dynamic class loader when it starts.

bozhidar15:05:42

@deg How did you do the update?

bozhidar15:05:07

@dpsutton No, I guess @cemerick is busy and he hasn’t seen the ticket.

deg15:05:11

@dpsutton lein deps :tree shows only 0.17..0. And nothing interesting in my ~/.lein/profies

dpsutton15:05:27

that's weird that it shows that. do you know why?

dpsutton15:05:41

this should be injected solely by CIDER. ie, your project shouldn't have any knowledge of it

deg15:05:07

Came from the Luminus template

deg15:05:41

Actually, the template had 0.15.1 and I updated it when warned by lein ancient

dpsutton15:05:31

delete it from the tmeplate

dpsutton15:05:37

let cider manage it

deg15:05:56

What brings in Cider?

dpsutton15:05:09

i thought you said it was in the template

deg15:05:36

Yes. I think we are talking past each other. ....

deg15:05:20

Luminus template created project.clj project.clj now contains

:dependencies [...    [cider/cider-nrepl "0.17.0"] ...

deg15:05:53

All mentions of Cider in project are:

./src/clj/diffusion/core.clj:6:            [cider.nrepl :refer [cider-nrepl-handler]]
./src/clj/diffusion/core.clj:31:                   :handler cider-nrepl-handler }))
./project.clj:7:                 [cider/cider-nrepl "0.17.0"]
./project.clj:52:   [cemerick.piggieback/wrap-cljs-repl cider.nrepl/cider-middleware]}

deg15:05:24

Ah... should line 52 go away? Was it needed in 0.15.1?

dpsutton15:05:33

no. it hasn't been needed since 9 or so i believe. just strip out all mentions of cider-nrepl. CIDER has been configured to inject its own dependencies so that you don't have to worry about keeping the behind the deps and the emacs version in sync

deg15:05:39

Hmm, I'm surprised that Luminus gets this wrong. So, you are saying that I should kill both lines in core.clj, right? And in project.clj, I assume I need to keep line 7, but should kill 52?

deg15:05:01

(fixed major typo there ... read edited version)

bozhidar16:05:39

I don’t think that’s a problem - I’m more curious why you’ve got CIDER 0.17-snapshot on the Emacs side.

deg16:05:42

Ah, I see. You really meant to remove all 4 lines. What magic you wizards weave! 🙂

bozhidar16:05:06

That’s why I asked how exactly did you do the upgrade. Maybe you didn’t restart Emacs afterwards?

deg16:05:18

I did an update i M-X List Packages... one sec, I'll check details.

deg16:05:53

And, definitely did a restart. My UPS battery died last week and we had a power blip so, umm, yeah, I did a restart. 😞

deg16:05:33

This is the Cider listed in List Packages: cider 20180509.109 installed Clojure Interactive Development Environment that Rocks

deg16:05:40

(my text reads funny. Meant to say that the battery died last week, I have't replaced it yet; and had a power blip today right after updating Emacs)

deg16:05:54

Hmmm... My Cider is 0.18.0snapshot in the header comment. I wonder if you updated to 0.18 and put in the word snapshot, but left "17" someplace?

bozhidar16:05:26

I don’t think so.

bozhidar16:05:40

Just checked this.

bozhidar16:05:36

But at any rate - if you’re using MELPA the chance is that you’d be either 0.17-snapshot or 0.18-snapshot. It’s unlikely you’ll be on 0.17 stable.

bozhidar16:05:08

Ah, I didn’t read the message carefully - yeah, you had installed 0.17-snapshot and from luminos you had the wrong middleware overriding the one CIDER injects itself. Mystery solved. 🙂

deg17:05:59

I still don't see where I had installed 0.17-snapshot. As far as I can see, I had 0.17 from my edit of Luminus, and 0.18-snapshot from MELPA.

dpsutton17:05:52

Oh I misunderstood the confusion sorry. Have you restarted emacs since upgrading? And you could grep the elpa directory for the version string. Also check mx cider-version

deep-symmetry18:05:22

Ok, I am trying to switch to use-package so I can have most things come from melpa-stable and get clj-refactor from melpa. I think I have that mostly set up, but for some weird reason I do not see any versions of clj-refactor from melpa. I only see the ancient 2.3.1 from melpa-stable!

justinbarclay18:05:16

@deep-symmetry What does your package-archives look like? Use package pulls from there, so unless you have ("melpa" . "") in there, it won’t know about it.

deep-symmetry18:05:39

Sorry, my fault… I did have melpa in there and was seeing other snapshots, but I had accidentally pinned clj-refactor to melpa-stable in overzealous use of my keyboard macro to change to using use-package.

arrdem18:05:49

@bozhidar Chas just transfered the repo!

deep-symmetry18:05:55

Sigh. But now I have CIDER 0.17.0 and refactor-nrepl 20180420.223 installed, and am still seeing this crash trying to jack in:

error in process sentinel: Could not start nREPL server: Could not find artifact refactor-nrepl:refactor-nrepl:jar:2.4.0-SNAPSHOT in central-mirror ()
Could not find artifact refactor-nrepl:refactor-nrepl:jar:2.4.0-SNAPSHOT in clojars-mirror ()
Could not find artifact refactor-nrepl:refactor-nrepl:jar:2.4.0-SNAPSHOT in releases ()
Could not find artifact refactor-nrepl:refactor-nrepl:jar:2.4.0-SNAPSHOT in snapshots ()
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

deep-symmetry18:05:23

Ah, that looks local.

deep-symmetry18:05:40

Temporarily turning off our clojars mirror allowed me to download the snapshot, I will have to talk to the person who set that up to find a more permanent solution.

jsa-aerial18:05:41

I am trying to get cider to work with clj 1.9, but I keep hitting this error: Error loading cider.nrepl.middleware.test: java.lang.RuntimeException: Invalid token: ::clojure.test/once-fixtures

jsa-aerial18:05:46

I have looked at various issues reporting this or things very close to it and have tried many combinations of cider/n-repl and tools.nrepl. It has defeated me at every step. If I go back to 1.8 things just work - no matter what combination of those I use. I know this has something to do with a change in 1.9 that now enforces an intent on keywords, but at this point I would have thought cider/n-repl 17 and tools.nrepl 2.13 would have the changes to fix this. Does anyone have any suggestions?

dpsutton18:05:18

that was due to a change in keywords. in 1.8 ::fully-qualified-namespace/var was legal. in 1.9 it no longer is. now its ::alias/var. This was updated in cider-nrepl a long time ago. can you tell me what version of cider you are on?

dpsutton18:05:21

wow. comments in that thread talk about a 0.15.1 release which will publish the fix. how old is your cider?

dpsutton18:05:30

(assuming its the same issue @jsa-aerial)

jsa-aerial18:05:21

As I mentioned - I know this has to do with a change in keyword processing and that I have tried all combinations of cider/n-rrepl from 0.13 up through and including 0.17.0 with both tools.nrepl 0.2.12 and 0.2.13

dpsutton18:05:05

can you delete the artifact in ~/.m2/repository/cider and make sure you're on a recent cider?

jsa-aerial18:05:08

You mean delete the entire directory recursively?

dpsutton18:05:50

i want to make sure you pull a new cider-nrepl artifact. the hope is that its one with that fix. i would just remove ~/.m2/repository/cider

jsa-aerial18:05:33

OK, something does seem weird - when I look in there I do see 0.15.1 and 0.16.0, but not things like 0.13 and 0.17 - despite having put those in the project.clj and saw what appeared to be dowload messages first time used.

dpsutton18:05:13

cider injects its own dependencies. just change your emacs cider version and you should get the correct (and matching) cider-nrepl

dpsutton18:05:55

(cider-add-to-alist 'cider-jack-in-lein-plugins
                    "cider/cider-nrepl" (upcase cider-version))

jsa-aerial18:05:16

I'm not even running emacs cider at this point - just tying to get lein repl to run

dpsutton18:05:35

oh. well then grab the latest cider-nrepl and try that then

dpsutton18:05:53

but if you're not using CIDER why do you have a dep on cider-nrepl?

jsa-aerial18:05:18

I have - I used both 15.1 and 0.17 - neither worked. But as I say, oddly 17 wasn't even in the repo (?!?)

dpsutton18:05:30

i'm not sure that you have tried 0.17 then

jsa-aerial18:05:59

it was in the project.clj when lein repl was invoked ...

jsa-aerial18:05:30

I've cleaned up the repo area - let me see if things are any better now

jsa-aerial18:05:31

OK, maybe this has something to do with where I'm putting these in the project.clj. I have them in [:profiles :dev], and maybe the ~/.lein/profiles.clj stuff is overriding that?

dpsutton18:05:58

yeah lein profile merging is complicated i've heard. why do you want to put cider-nrepl into any of those?

dpsutton18:05:13

do you use vim fireplace or something?

jsa-aerial18:05:50

OK, putting those at the 'top level' fixes the original problem but now introduces Error loading refactor-nrepl.middleware: java.io.FileNotFoundException: Could not locate cider/nrepl/middleware/util/misc__init.class

jsa-aerial18:05:47

Generally I would only put the dependencies in ~/.lein/profiles.clj, but in this particular case I was trying to see if things would actually work before committing to moving to 1.9

dpsutton18:05:10

why do you want to put an explicit dependency on cider-nrepl? I still don't follow your use case

jsa-aerial18:05:53

I never use jack in - I always start separate servers and connect. I have found that to be far more useful and productive

dpsutton18:05:18

ah ok. i follow you.

jsa-aerial18:05:32

I'm guessing I now have some odd mismatch with refactor-nrepl. I suppose I could get rid of that altogether - I find I don't really use if much

jsa-aerial19:05:52

Yeah, refactor-nrepl is just broken - if I remove it from plugins things now work - and I was using the most recent version 2.3.1. I've had a lot of problems with it in the past as well. There are some nice things in it but it just doesn't seem to play well with the rest of the stack

jsa-aerial19:05:44

^^^ If you use 2.4.0-SNAPSHOT of refactor-nrepl it works - there are multiple issues on this and suggestion to use the snapshot with latest cider-nrepl...

bozhidar20:05:37

Yeah, as I mentioned a few times - the development of refactor-nrepl is mostly independent from CIDER and the releases are sometimes out of sync.

bozhidar20:05:20

Not much I can do about this.

bozhidar20:05:02

Now it’s time to figure out how to handle the first release. Likely I’ll follow the original plan and just release nREPL 0.3 with a new coordinate and the old namespace and afterwards we have to decide how to handle the ns transition.

bozhidar20:05:03

Changing the namespaces in our projects is easy, but that’s we might have to create new tasks for boot and lein until the dep gets changed upstream.