Fork me on GitHub
#nrepl
<
2022-03-27
>
pez12:03:09

@vemv I'm trying to add enrich-classpath support to Calva. I'm at where the jack-in command looks like so when enrichment is enabled:

lein update-in :dependencies conj '[nrepl,"0.9.0"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.27.4"]' -- update-in :plugins conj '[mx.cider/enrich-classpath,"1.9.0"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.enrich-classpath/middleware"]' -- with-profile +repl repl :headless
However, jacking in I see the nREPL server start, but can't see any activity from enrich-classpath. Do I need to do anything else for this to happen?

vemv16:03:08

I'll be on it in a bit, in the meantime I'd appreciate moving the convo to the Calva GH issue 😇

vemv16:03:50

enrich-classpath isn't nrepl middleware, it's Lein middleware Lein usage expects the plugin and Lein middleware to be activated

🙏 1
borkdude21:03:15

@U0ETXRFEW FWIW, @UKFSJSM38 and I are working on downloading the jdk classes locally in a cached zip file so they can be used for analysis + navigation. Perhaps calva could also use these. Adding the jdk as a git dep is fun, but probably a bad idea ;)

👍 1
pez22:03:27

It might be a bad idea, but it seems something is broken when it throws errors like it did when I tried.

vemv06:03:45

downloading anything for the jdk is something I deliberately decided not to do. It's generally not necessary as the sources already are in the filesystem, along the JRE. enrich-classpath locates them, accurately for the precise jdk being used, and copies/zips/unzips them depending on what does one need to do (varies per JDK - 8 vs 9+) otherwise downloading jdks, besides from redundant (vs. what it's at hand already), seems prone to mismatches (e.g. different bugfix release, different distribution) or even licensing issues. in many Linux distros (but often not in CI!) sadly the sources are not installed along the JRE. In that case enrich-classpath simply logs a warn which is expanded in the README. It seems wise to let users understand the design of their distro and to have complete installation scripts (which means just running a one-liner)

vemv06:03:39

Even after solving the "JDK sources" problem, then you'll want to solve the "Maven deps' sources" problem, and then "Lein and tools.deps" problem ...at which point you've basically implemented enrich-classpath :) I'd be super happy to receive an issue/PR if there's something that introduces friction. Other than that, like any decent program, Enrich is made of composable primitives which can be easily repurposed.

ericdallo13:03:13

Thanks for the explanation @vemv, I was not aware that most JRE had src.zip available, that will make things better, would you mind elaborate or point to where enrich-classpath checks for JDK local? for clojure-lsp we may have the download as fallback but checking for local src.zip on specific places makes sense

ericdallo14:03:04

I'll make some adaptations for clojure-lsp since that expects (System/getProperty "java.home") is available, but for graal images it's not

vemv16:03:45

:thumbsup: ! (worth emphasizing, this src.zip file is absent in many linux distros - the user would have to run sudo apt install openjdk-11-source or such - just like he would have to for many other purposes)

👍 1
pez21:03:59

I tried to add openjdk as a dependency in a project, like @borkdude does here: https://twitter.com/borkdude/status/1508156961958858757 But when the repl has started a ton of exceptions are thrown with the same type of error.

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.8.3"},cider/cider-nrepl {:mvn/version,"0.25.5"}}}' -M:repl -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
Checking out:  at c2c0cb2a4372d78658326461562363de9a1a194f
nREPL server started on port 58645 on host localhost - 
java.lang.NullPointerException: Cannot invoke "jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration.getOptions()" because "this.configuration" is null
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.getSupportedOptions(HtmlDoclet.java:426)
        at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.getSupportedOptions(StandardDoclet.java:93)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java.parser$parse_java$reify__4919.getSupportedOptions(parser.clj:77)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.getSupportedOptionsOf(Start.java:647)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.consumeDocletOption(Start.java:595)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseArgs(Start.java:801)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:498)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:393)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:355)
        at jdk.javadoc/jdk.javadoc.internal.api.JavadocTaskImpl.call(JavadocTaskImpl.java:104)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java.parser$parse_java.invokeStatic(parser.clj:87)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java.parser$parse_java.invoke(parser.clj:64)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java.parser$source_info.invokeStatic(parser.clj:299)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java.parser$source_info.invoke(parser.clj:290)
        at clojure.lang.Var.invoke(Var.java:384)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java$class_info_STAR_.invokeStatic(java.clj:198)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java$class_info_STAR_.invoke(java.clj:189)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java$class_info.invokeStatic(java.clj:236)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java$class_info.invoke(java.clj:228)
        at cider.nrepl.inlined_deps.orchard.v0v6v1.orchard.java$eval5144$fn__5145.invoke(java.clj:403)
        at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
        at clojure.lang.AFn.call(AFn.java:18)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
java.lang.NullPointerException: Cannot invoke "jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration.getOptions()" because "this.configuration" is null
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.getSupportedOptions(HtmlDoclet.java:426)
        at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.getSupportedOptions(StandardDoclet.java:93)
...
And code navigation to Java sources does not start to happen.