Fork me on GitHub
#practicalli
<
2023-08-12
>
Zachary14:08:40

Hi there! I’m trying to get code lookup for Clojuer Java source to work. Using the Practicalli deps.edn. I have the Java docs working great (which is super awesome)! I have the clojure source cloned from the repo, and am using emacs with cider-jack-in to connect to the REPL. Here’s what my :src/clojure alias and my cider-clojure-cli-global-options look like:

;; in ~./clojure/deps.edn
:src/clojure
{:extra-paths ["src/jvm"]
:extra-deps
{org.clojure/clojure-source {:local/root "/Users/<my-username>/drausen/clojure"}}}

;; from emacs config
(setq cider-clojure-cli-global-options "-A:src/clojure:src/java20:dev/reloaded:portal")
When I jack in, my portal config pops up and I get the success greeting from cider... and no warnings. Java lookup works, but when I try to look up a Java source of Clojure with xref-find-definitions, I get a “user-error: No definitions found” message. Any directions or help appreciated! Thank you so much!

practicalli-johnny15:08:35

cider-clojure-cli-aliases is the correct Cider variable to use to add aliases The global options variable is depreciated anday have strange side effects The -A execution flag isn't required (all flags are stripped out by the Cider code)

Zachary15:08:32

Hmmm... so with: (setq cider-clojure-cli-global-options "") (setq cider-clojure-cli-aliases ":src/clojure:src/java20:dev/reloaded:portal") It doesn’t seem to be picking up the :src aliases? And Java lookup also not being found. Jack in nREPL message: [nREPL] Starting server via /opt/homebrew/bin/clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.0.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.32.0-alpha1\"\}\ refactor-nrepl/refactor-nrepl\ \{\:mvn/version\ \"3.9.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[refactor-nrepl.middleware/wrap-refactor\,cider.nrepl/cider-middleware\]\"\]\}\}\} -M:dev/reloaded:cider/nrepl

practicalli-johnny19:08:04

SPC u before the jackin key binding will show an editable jack-in command in the mini-buffer

practicalli-johnny19:08:41

Or start the REPL in a terminal with the Clojure or clj command with the appropriate aliases, then use cider-connect (instead of jack-in) I'll try replicate in the morning. There have been a few changes recently in Cider, so not sure if it's those or something missing in the aliases If you can share a small reproduction repository the demonstrates the issue that would help

Zachary19:08:49

All great info, appreciate it! I guess I’m a bit embarrassed to ask, what the best way to start an nrepl-enabled session in another terminal? (I usually just use cider-jack-in to handle all the “magic”.) I did update cider to the latest versions, and pulled the latest practicalli config (updated my :src/clojure to point to my local repo), but still not getting clojure java sources found.

Zachary19:08:42

Also, another question: what’s the best way to include java options? I usually also just through those into cider-clojure-cli-global-options

Zachary19:08:30

My nREPL version and commands: ;; CIDER 1.8.0-snapshot (package: ), nREPL 1.0.0 ;; Clojure 1.11.1, Java 20 ;; Startup: /opt/homebrew/bin/clojure -A:src/clojure:src/java20:dev/reloaded:portal -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.0.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.35.0\"\}\ refactor-nrepl/refactor-nrepl\ \{\:mvn/version\ \"3.9.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[refactor-nrepl.middleware/wrap-refactor\,cider.nrepl/cider-middleware\]\"\]\}\}\} -M:cider/nrepl

practicalli-johnny20:08:27

Practicalli Clojure CLI config has an alias calle :repl/basic which adds an nrepl server Run clojure with that alias in the root of the project

clojure -M:repl/basic

👀 2
practicalli-johnny20:08:01

Aliases can be chained together

clojure -M:src/clojure:src/java20:repl/basic

practicalli-johnny20:08:11

JVM options can be added to an alias, e.g

:performance/memory-meter
  {:extra-deps {com.clojure-goes-fast/clj-memory-meter {:mvn/version "0.3.0"}}
   :jvm-opts   ["-Djdk.attach.allowAttachSelf"]}

🙏 2
practicalli-johnny20:08:35

Or JVM options can be passed on the command line https://practical.li/clojure/reference/jvm/

Zachary20:08:33

Agh, this is looking like issues with cider… maybe I should be mentioning this over there… Getting errors on cider-locate-running-nrepl-ports [:line 1825], where it’s taking the directory-path as argument, inferring the correct port, and returning a list ("my-directory" "51115") and trying to call directory-file-name on that list.

Zachary20:08:15

I also have a few other REPLs running, so calling cider-locate-running-nrepl-ports without an argument, returns a list of lists with projects-directories with their nrepl ports. Maybe I try to halt those processes, and try again. Anyways, hopefully feedback useful.

Zachary20:08:58

^The jvm options is precisely for running clojure-goes-fast projects ^_^ 👍

practicalli-johnny21:08:12

I suggest comment any code or variables that have anything to do with Cider in the Emacs configuration. Also check for.dir-locals.el (although that file only affects. Cider jack-in) Make sure that Cider package is fairly recent, from 2023 at least Then if there are still problems the #C0617A8PQ channel may have more ideas

Zachary22:08:09

Ok, the cider folks got back to me, it was certainly an issue that they just recently pushed, so the connection is resolved. The Cider version 1.8.0-snapshot is complaining that it requires cider-nrepl 0.35.0, but the version in :repl/basic is using 0.31.0, so bumping that and seeing if we get a bit further.